C program to read and display 5 integer values in 1-D array

C program to read and display 5 integer values in 1-D array

  1. #include<stdio.h>
  2. int main()
  3. {
  4.  int i=0, number[5];
  5.   for(i=0; i<5; i++) // This loop tracks array index 
  6.    {
  7.      printf("Enter your Number[%d]:",i);
  8.        scanf("%d",&number[i]);
  9.         }
  10.          //Logic to print number array.
  11.           for(i=0; i<5; i++) // This loop tracks array index 
  12.            {
  13.              printf("Number[%d]:%d \n", i, number[i]);
  14.               }
  15.               } 

Output


Enter your Number[0]:2
Enter your Number[1]:4
Enter your Number[2]:6
Enter your Number[3]:8
Enter your Number[4]:10
Number[0]:2
Number[1]:4
Number[2]:6
Number[3]:8
Number[4]:10

Choose next program from this list

Comments