Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

Write the code for a program that takes in an integer from the user and then calculates
the sum of all the numbers from 1 to the integer entered by the user. For example,
suppose the user entered the number 4; now, the output should be 10.

Sagot :

Answer:

Explanation:

#include<stdio.h>

#include<conio.h>

int main(){

int a,b=1,sum=0;

printf("Enter the number:");

scanf("%d",&a);

while(b<=a){

sum=sum+b;

b=b+1;

}

printf("The sum is %d\n",sum);

getch();

}