Grrr!.....for me this is not a practice....because its hard to get it!........
so help me for my practice!....
my problem is i want to know how to get the lowest input of integers input by user with loop!....i get the highest integer...but in the lowest is the same with highest!.....
like a enter number 1 2 3 4 5
the highest is 5[correct]
the lowest is 5[wrong] ... plz help how to solve it
2nd problem is i want to know how to reverse that input of integers input by user with loop!..just like 1 2 3 4 5....and its same value like int a using loop!....scanf is the inside of the loop....looping 5 times...and i want to know how to reverse...that one value!....
plz help me in my two problems!....(don't use array) because in that topic i can't understand...i'm the C functions topic
here's my code!>..
Code:#include<stdio.h> #include<conio.h> #include<math.h> #include<stdlib.h> int add(int sum1); int pro(int pro1); int highest(int a); int lowest(int a); double sq(int sum1); double sq2(int pro1); int rev(int a); main(){ int a; int sum1=0; int pro1=1; printf("Enter 5 numbers: "); for(int b=1;b<=5;b++){ scanf("%d",&a); sum1+=a; pro1*=a; } printf("\n[1] Sum and Product"); printf("\n[2] Highest and Lowest input"); printf("\n[3] Square Root of the Sum and Product"); printf("\n[4] Reverse Order of the Inputs"); printf("\n[5] Exit"); int choice; printf("\n\nEnter Choice: "); scanf("%d",&choice); system("cls"); if(choice==1){ printf("\nSum is %d",add(sum1)); printf("\nProduct is %d",pro(pro1)); char repeat; printf("\n\nGo Back to Main?[y/n] "); scanf("%s",&repeat); if(repeat=='y'){ system("cls"); return main(); } else { return 0; } } else if(choice==2){ printf("\nHighest Input is %d",highest(a)); printf("\nLowest Input is %d",lowest(a)); char repeat; printf("\n\nGo Back to Main?[y/n] "); scanf("%s",&repeat); if(repeat=='y'){ system("cls"); return main(); } else if(repeat=='n'){ return 0; } } else if(choice==3){ printf("\nSquare Root Value of the Sum is %.2f",sq(sum1)); printf("\nSquare Root Value of the Product is %.2f",sq2(pro1)); char repeat; printf("\n\nGo Back to Main?[y/n] "); scanf("%s",&repeat); if(repeat=='y'){ system("cls"); return main(); } else { return 0; } } if(choice==4){ printf("\nReverse Order is "); printf("\n\n%d ",rev(a)); char repeat; printf("\n\nGo Back to Main?[y/n] "); scanf("%s",&repeat); if(repeat=='y'){ system("cls"); return main(); } else if(repeat=='n'){ return 0; } } else if(choice==5); return 0; getch(); } int add(int sum1) { int add=0; add=sum1; return add=sum1; } int pro(int pro1) { int pro2=1; pro2=pro1; return pro2=pro1; } int highest(int a) { int high=0; if(high < a) { high=a; } return high; } int lowest(int a) { int low='a'; if(low > a) { low=a; } return low; } double sq(int sum1){ double two; two=sqrt(sum1); return two; } double sq2(int pro1){ double one; one=sqrt(pro1); return one; } int rev(int a){ int m=a; int b,c=0; b=a%10; c=(c*10)+b; a=a/10; return c; }