Question #14368

write a program that calculates the sum of n numbers

Expert's answer

#include<stdio.h>

#include<conio.h>

main()

{

int num,

n,sum=0,i=0;

printf("Enter the number of elements to be added:

");

scanf("%d",&n);

printf("Enter %d

numbers",n);

while(i<n)

{

scanf("%d",&num);

sum=sum+num;

i=i+1;

}

printf("The sum of

%d numbers is %d",n,sum);

getch();

}

#include<conio.h>

main()

{

int num,

n,sum=0,i=0;

printf("Enter the number of elements to be added:

");

scanf("%d",&n);

printf("Enter %d

numbers",n);

while(i<n)

{

scanf("%d",&num);

sum=sum+num;

i=i+1;

}

printf("The sum of

%d numbers is %d",n,sum);

getch();

}

## Comments

## Leave a comment