In: Computer Science
Write the complete code necessary to prompt the user for 4 sequential numbers, calculate the summation of the 4 numbers and display the results including the words "The summation of 1,2,3,4 is". A summation is defined as n + n+1 + n+2.... Declare necessary variables and be sure to include comments. Include int main(void) { Code goes here } The programming language is C in Visual Basic
#include<stdio.h>
int main(){
int n1,n2,n3,n4,total;
printf("Enter number1:");
scanf("%d",&n1); //read the number from the user
printf("Enter number2:");
scanf("%d",&n2); //read the number from the user
printf("Enter number3:");
scanf("%d",&n3); //read the number from the user
printf("Enter number4:");
scanf("%d",&n4); //read the number from the user
total=n1+n2+n3+n4; //calcualte the sum
printf("The summation of %d,%d,%d,%d is %d\n",n1,n2,n3,n4,total); //here print the sum of numbers
return 0;
}