wew.. when i try to changeandCode:big=a[i]toCode:low=a[0];andCode:big=a[0];the result wasCode:low=a[0];
the smallest number is = 1
the largest number is = 1
[code]
if(a[i]>big)
big=a[i];
else
if(a[i]<low)
low=a[i];
[/code
wew.. when i try to changeandCode:big=a[i]toCode:low=a[0];andCode:big=a[0];the result wasCode:low=a[0];
the smallest number is = 1
the largest number is = 1
[code]
if(a[i]>big)
big=a[i];
else
if(a[i]<low)
low=a[i];
[/code
I meant you should replace line #11 of post #7 with "big = low = a[0];"
Devoted my life to programming...
Fix:
Code:#include<stdio.h> #include<conio.h> /* outdated/nonportable */ #include<stdlib.h> int add(); int multiply(); int hv=0; /* useless global */ int lv=1; /* useless global with random "magic number" value */ int exit(); /* bad name for a function, already included in std. C */ main() /* no implicit main, make it int main instead */ { int a, b, c, d,e,f; /* not descriptive/useful names */ system("color F0"); /* non portable */ f=0; e=1; /* magic numbers again? */ d=1; printf("Enter number of inputs: "); scanf("%d", &a); if((a>19)||(a==0)) { printf("\nINVALID INPUT.."); system("cls"); getch(); /* get rid of this, and anything else from conio.h */ return main(); /* just exit. or, use a while loop */ } /* example of the above code with a while loop */ a = 0; while ((a > 19) && (a != 0)) { printf("Enter number of inputs (1-19): "); scanf("%d", &a); } for(b=0; b<a; b++) { printf("\nEnter a number: "); scanf("%d", &c); f=f+c; e=e*c; } printf("\nThe sum is %d and the product is %d", f, e); printf("\n\nWant to try again? [1] Yes [other Digits] No: "); scanf("%d", &d); if(d==1){system("cls");return main();} if(d!=1){system("cls");exit();} getch(); } int exit() /* already a function */ { return 0; /* completely useless, this does literally nothing */ }
ohh i see... the only problem i have now is how to combine these codes..
this is for finding the sum and prod
Code:#include<stdio.h> #include<conio.h> #include<stdlib.h> int add(); int multiply(); int hv=0; int lv=1; int exit(); main() { int a, b, c, d,e,f; f=0; e=1; d=1; printf("Enter number of inputs: "); scanf("%d", &a); if((a>19)||(a==0)) { printf("\nINVALID INPUT.."); system("cls"); getch(); return main(); } for(b=0; b<a; b++) { printf("\nEnter a number: "); scanf("%d", &c); f=f+c; e=e*c; } printf("\nThe sum is %d and the product is %d", f, e); printf("\n\nRepeat the Process? [Press [1] for yes, other #'s for exit]"); scanf("%d", &d); if(d==1){system("cls");return main();} if(d!=1){system("cls");exit();} getch(); } int exit() { return 0; }
and this is for the largest and smallest number
Code:#include <stdio.h> #include <conio.h> main() { int a[5],i,big,low; printf("Enter 5 Number\n\n"); for(i=0;i<5;i++) scanf("%d",&a[i]); big=a[0]; for(i=0;i<5;i++) { if(a[i]>big) big=a[i]; else if(a[i]<low) low=a[i]; } printf("\nLargest Number is=%d\nSmallest Number is=%d ",big,low); getch(); }
plss help me... i have really a big problem.. i dont know how to arrange the code..