top of page
Writer's pictureanitadevkar

Array Accept and Display

#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



4 views0 comments

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...

Comments


bottom of page