How do I store the value of the max integer in an array before repeating loop? -
it's been couple hours. don't understand arrays enough determine right way save value max , determine maximum value within array. please explain how make loop correctly. thanks.
#include <stdio.h> #include <conio.h> #define size 3 int main (void){ int max; int min; int myarray[size]; int count; printf("please enter integers\n"); (count=0;count<=size;count++){ scanf("%d",&myarray[count]); } (count=0;count<=size;count++){ printf("the values of myarray %d\n",myarray[count]); } (count=0;count<=size;count++){ max=myarray[0]; if (myarray[count]>max){ myarray[count]=max; } } printf("the largest %d\n",max); printf ("the smallest %d\n",min); getch(); return 0; }
max=0; (count=0;count<size;count++){ if (myarray[count]>max){ max = myarray[count]; } }
you need change <= size < size
Comments
Post a Comment