PDA

View Full Version : Help need for a C program! SOS


Gigacore
22-08-2007, 10:30 PM
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[i])

and the print statement

Garbage
22-08-2007, 10:40 PM
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.

Gigacore
22-08-2007, 10:47 PM
EXECUTED, its working.


+++ RESOLVED +++

arunks
22-08-2007, 10:54 PM
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