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.