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
Post a Comment
Please feel free to comments if you have any ideas, questions and subjection concerning our post and programs