Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a program which calculate sum of several number and input it into an array. Then, the sum of all the number in the array is calculated.

Answer Posted / pradeepnair

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

void main()
{
int val1;
int val2;
int size=0;
int a,b[100];
int i,n,j,k=1;
int sum=0;
int sum1=0;
printf("enter the no of values to be added");
scanf("%d",&val1);
for(i=0;i<val1;i++)
{
scanf("%d",&a);
sum=sum+a;
}
System.out.println("the sum is"+sum);
while(sum>0)
{
val2 = sum%10;
sum=sum/10;
b[k]=val2;
size=size+1;
k--;
}
printf("the values in array are");
for(i=0;i<size;i++)
{
printf("/n",b[i]);

}

for(j=0;j<size;j++)
{
sum1=sum1+b[j];
}
printf("the sum of values an array is $d",sum1)

getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does p mean in physics?

992


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

2065


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1219


What is difference between far and near pointers?

989


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

4242


What is the purpose of type declarations?

1079


Here is a neat trick for checking whether two strings are equal

969


What is keyword in c?

966


Which is better oop or procedural?

995


Why does everyone say not to use gets?

1029


Why is void main used?

1036


Explain output of printf("Hello World"-'A'+'B'); ?

1434


What is the purpose of the statement: strcat (S2, S1)?

1081


What is a nested formula?

1057


What is New modifiers?

1062