//WAP to input n number in array & find largest number #include<stdio.h> #include<conio.h> void main() { int i,num[100],g,n; clrscr(); printf("Enter any value of n:\n"); scanf("%d",&n); printf("Entre any value in array:\n"); scanf("%d",&num[i]); for(i=0;i<n;i++) scanf("%d",&num[i]); g=num[0]; for(i=0;i<n;i++) { if(num[i]>g) g=num[i]; } printf("Greater num = %d",g); getch(); }
// WAP to enter three numbers and find middle number among them. #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( ( a > b && a < c ) || ( a > c && a < b ) ) printf ( "%d is middle number" , a ) ; else if ( ( b > a && b < c ) || ( b > c && b < a ) ) printf ( "%d is middle number" , b ) ; else printf ( "%d is middle number" , c ) ; getch ( ) ; } Output:
Comments
Post a Comment