Please give some effort when you post a question. This is a simple task you could learn by reading a book on C. You need to read in characters from the user and then store those values in the array. Look into fgets() and getchar().
ok i try it. but i don't want to use fgets() and getchar(). I need to display the smallest and largest value in the array.
the program does not contain error but it is not displaying the correct values. Whats wrong with it?
int main ()
printf ("Enter the values of the Array: ");
printf("Largest: %i ",largest);
printf("Smallest: %i \n",smallest);
You never initialize the variable "largest". On line 23, you assign A to an uninitialized value. When you go through A to find the largest value, A could be anything. When I tested it, it was 32767.
I recommend compiling with the compiler option -Wall. That enables all warnings. When I compiled with that option while using GCC 4.4.3, it said this:
$ gcc -Wall -o array_sizes array_sizes.c
array_sizes.c: In function ‘main’:
array_sizes.c:51: warning: control reaches end of non-void function
array_sizes.c:23: warning: ‘largest’ is used uninitialized in this function
That second warning tells you that you're using an uninitialized variable.
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"