top of page
Search

Array Accept and Display

  • Writer: anitadevkar
    anitadevkar
  • Feb 28, 2022
  • 1 min read

#program to accept and display values of an array

#include <stdio.h>

int main()

{

int a[15],n,i;

printf("Enter how many elements do you want to store into an array");

scanf("%d",&n);

for(i=0;i<n;i++) //accepting array elements from user

{

printf("Enter %d value=",i+1);

scanf("%d",&a[i]);

}

printf("Entered Values are =");

for(i=0;i<n;i++) //Displaying array elements

{

printf("%d ",a[i]);

}

return 0;

}

Output: Testcase-1

Enter how many elements do you want to store into an array 4

Enter 1 value=12

Enter 2 value=43

Enter 3 value=34

Enter 4 value=9

Entered Values are =12 43 34 9



 
 
 

Recent Posts

See All
C Program for pyramid of number

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=1;j<=i;j++) //for columns j loop will iterate...

 
 
 
Program to print Triangle

Program: #include <stdio.h> int main() { int i,j; for(i=5;i>0;i--) //for rows { for(j=0;j<i;j++) //for columns j loop will iterate...

 
 
 

留言


bottom of page