Friday, March 28, 2014

Ask the user to tell that the sum of how many integers he wants to calculate. Get value for each integer & calculate the sum of all the integers enetered by the user.

#include<stdio.h>
#include<stdlib.h>
void line()
{
int i,j;
printf("\n");
for(i=1;i<=42;i++)
printf("=");
}
void header()
{
printf("\n");
printf("Built and Designed by Arslan Malik\n\n www.CworldbyAS.blogspot.com");
printf("\n");
}
int main()
{
line();
header();
line();

int value,number,a,sum=0;
printf("\nEnter the number of values : \n");
scanf("%d",&number);
for(a=1;a<=number;a++)
{
    printf("Enter Integer : ");
    scanf("%d",&value);
    sum=sum+value;
}
printf("Sum of %d values is : %d \n\n",number,sum);

return 0;
}

No comments:

Post a Comment