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 4 numbers:");
scanf("%d%d%d%d",&n1,&n2,&n3,&n4); //read the 4 numbers 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
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.