Q. Write a program to create array.
Ans.
/*c program for creation of array or list of numbers*/
#include<stdio.h>
#include<conio.h>
#define SIZE 50
int main()
{
int arr[SIZE];
int i,num;
printf("Enter total number of elements : ");
scanf("%d", &num);
for(i=0; i<num; i++)
{
printf("Enter %d element : ",i+1);
scanf("%d", &arr[i]);
}
printf("\n-- Creation of array --\n\n");
for(i=0; i<num; i++)
printf("\t%d\n", arr[i]);
getch();
return 0;
}
/**************** Output ******************/
Related programs:
Ans.
/*c program for creation of array or list of numbers*/
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[SIZE];
int i,num;
printf("Enter total number of elements : ");
scanf("%d", &num);
for(i=0; i<num; i++)
{
printf("Enter %d element : ",i+1);
scanf("%d", &arr[i]);
}
printf("\n-- Creation of array --\n\n");
for(i=0; i<num; i++)
printf("\t%d\n", arr[i]);
getch();
return 0;
}
/**************** Output ******************/
Screen shot for creation of array |
Related programs:
No comments:
Post a Comment