Help need for a C program! SOS

Status
Not open for further replies.

Gigacore

Dreamweaver
Hi guys i'm new to C programming. I've a small assignment program,

Write a Program to accept 10 numbers using one dimensional array and display them.

here how i tried, but haven't executed.

int a[10],i,n;
printf(Enter the number of elements");
scanf("%d", &n);
printf("Enter the elements");
for (i=0;i<n;i++)
scanf("%d", &a)

and the print statement
 

Garbage

God of Mistakes...
Then what is the problem ???
All the statements can work.

Only problem can arise is that if I enter number of elements as >10, then it will overwrite to some other memory area.
 

arunks

Hey here is the aks
after ur last statement i.e.scanf statement there will be a ; semicolon


and ya when value is n is less than 10 then it will work surely but if input value of n greater than 10 then it will produce errors as that will be on garbage addresses
 
Status
Not open for further replies.
Top Bottom