Adding And Subtracting N numbers



Write  a program that asks the user to input any arbitrary N numbers and Adds and Subtracts it .








Solution:
/* Adding N numbers */

#include<stdio.h>

int main(void)
{
    int n, sum=0, sub=0,mul=0, c, value;

    printf("Enter the number of integers you want to add\n");
    scanf("%d", &n);

    printf("Enter %d integers\n", n);

    for(c=1;c<=n; c++){
        scanf("%d", &value);
        sum= sum+value; /*adding each no in sum */
        sub= value-sub;


    }


    printf("Sum of entered Integers =%d\n", sum);
    printf("Difference  of entered Integers=%d\n", sub);


    return 0;
}

Comments

Popular posts from this blog

Body Mass Index Calculator In C

Adding two Integers in Java Application

Calculating Product, sum, difference, and quotient of Five Integers