Saturday, 22 July 2017

Write a program that sums the sequence of integers

Write a Code in C language that sums the sequence of integers.

Assuming that the first integer read specifies the number of values remaining to be entered. Program should read only one value per input statement.  A typical input sequence might be.
5 100 200 150 300 500 .

Where the 5 indicates that the subsequent 5 values are to be summed.


What is integer number?



An integer (pronounced IN-tuh-jer) is an entire variety (not a fractional number) that can be positive,  negative, or 0.

Examples of integers are: -5, 1, 5, 8, 97, and 3,043.
Examples of numbers that are not integers are:-1.43, 1 3/4, 3.14, .09, and 5,643.1.

The set of integers, denoted Z, is officially described as follows:

Z = {..., -3, -2, -1, 0, 1, 2, 3, ...}

Code:


#include<stdio.h>
#include<conio.h>
void main()
{
 int sum=0;
 int n,i;
 int value;
 printf("Enter The Numbers Of Values To Be Processed ");
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 printf("Enter A value: ");
 scanf("%d" ,&value);
 sum+=value;
 }
 printf("Sum Of %d Values Is %d\n",n,sum);
 getch();
 clrscr();
}


Try it yourself.
If you have any problem you can tell me on comment box i will help you.
thanks.


Viral Programs

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.

0 comments:

Post a Comment