PDA

View Full Version : C Programming Help


Sudantha_s
12-04-2008, 10:26 PM
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[i]);
}

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

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


}

Sudantha_s
12-04-2008, 10:32 PM
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[i]);
}

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

{sum=arr[i]+sum;

}

printf("%d",sum);

isira87
12-04-2008, 10:36 PM
:D

Sudantha_s
12-04-2008, 10:37 PM
:D
:rofl:

madurax86
12-04-2008, 10:45 PM
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??

Sudantha_s
12-04-2008, 10:53 PM
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??


tabbing is important as you say :D , but ek doesnt allow spaces :) :yes: