1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include<stdio.h> #include<conio.h> void main() { int a,b,c,large; clrscr(); printf("ENTER 3 NUMBERS\n"); scanf("%d%d%d",&a,&b,&c); if(a<b) large=b; else large=a; if(c>b) large=c; printf("THE LARGE NUMBER IS %d",large); getch(); } |
Search This Blog
Wednesday, 4 September 2013
FIND LARGE NUMBER FROM 3 NUMBERS
CATOGORIZE ODD NUMBERS AND EVEN NUMBERS SPERATLY.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #include<stdio.h> #include<conio.h> int i,n; struct numbers { int n1,odd,even; }num[90]; void main() { void read(); void display1(); void display2(); clrscr(); printf("ENTER LIMIT\n"); scanf("%d",&n); read(); display1(); display2(); getch(); } void read() { printf("\n ENTER %d NUMBERS\n",n); for(i=1;i<=n;i++) { scanf("%d",&num[i].n1); } } void display1() { printf("\nODD NUMBERS\n"); for(i=1;i<=n;i++) { if(num[i].n1%2==1) printf("\t %d ,",num[i].n1); } } void display2() { printf("\n EVEN NUMBERS\n"); for(i=1;i<=n;i++) { if(num[i].n1%2==0) printf("\t %d ,",num[i].n1); } } |
CONVERT A LIST OF NUMBERS TO A SPECIFIED NUMBER.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include<stdio.h> #include<conio.h> #include<string.h> int n,i,i2,i3; struct number { int number; }num[50]; void main() { void read(); void display(); void replace(); clrscr(); printf("ENTER LIMIT OF HOW MANY NUMBER ENTER TO LIST\n"); scanf("%d",&n); read(); display(); replace(); getch(); } void read() { printf("ENTER NUMBERS\n"); for(i=1;i<=n;i++) { scanf("%d",&num[i].number); } } void display() { for(i=1;i<=n;i++) { printf("\t %d , ",num[i].number); } } void replace() { printf("\n \n REPLACE\t"); scanf("%d",&i2); printf("\n \n TO\t"); scanf("%d",&i3); printf("SPECIFIED NUMBER REPLACED \n"); for(i=1;i<=n;i++) { if(num[i].number==i2) num[i].number=i3; printf("%d ,",num[i].number); } } |
Subscribe to:
Posts (Atom)