C Programming Help

Sudantha_s

Member
Feb 2, 2007
3,516
7
0
Assassin Brotherhood
I Need to write a Program using arrys and Loops to Get a Sum of Ten Numbers :D

--------------------------

whats da wrong of this coding :confused: , im gettting a junk value :P :rofl:


#include<stdio.h>
#include<conio.h>

main()
{

int arr[10];
int i,sum=0;

for (i=1;i<10;i++)

{
printf("Enter Ten Numbers : ");
scanf("%d",&arr);
}

for (i=1;i<10;i++)

{sum=arr+i;
printf("%d",sum);


}
 

Sudantha_s

Member
Feb 2, 2007
3,516
7
0
Assassin Brotherhood
Correct Code :D


#include<stdio.h>
#include<conio.h>

main()
{

int arr[10];
int i,sum=0;

for (i=1;i<10;i++)

{
printf("Enter Ten Numbers : ");
scanf("%d",&arr);
}

for (i=1;i<10;i++)

{sum=arr+sum;

}

printf("%d",sum);
 

madurax86

Member
Jun 29, 2006
4,385
88
0
hmm im on c++; ah :P i c silly one those things happen man just nest your statements well
like

main{
____for (i=0;i<10;i++){
____}
}

ek doesnt allow spaces/tabs??
 
Last edited: