0
Is it possible to declare array size in run time in c programming?
Because I can't judge what the Customer want the array size as?.........if it's possible so that he enter the array size as he want and I will show him the output in a easy manner?.....so please tell me it is possible or not? https://code.sololearn.com/c4HH4UILom5K/?ref=app
3 odpowiedzi
+ 2
YES YOU CAN DECLARE SIZE OF AN ARRAY AT RUN TIME.
HERE I AM SHOWING YOU AN SMALL EXAMPLE.
https://code.sololearn.com/cJZIB0g7ZcSG/?ref=app
+ 1
Just a little correction to MEET MEHTA answer, the array would be more suitable be declared after input of <n> is obtained, through user input.
#include <stdio.h>
int main() {
int n;
printf("ENTER NO. OF MARKS YOU WANT TO STORE\n");
scanf("%d",&n);
int a[n];
printf("ENTER %d MARKS YOU WANT TO STORE\n",n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("MARKS YOU HAD STORED ARE\n");
for(int i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
0
Thanks MEET MEHTA.......Thank u so much