WAP to print the sum of all numbers up to a given number.
#include <stdio.h>
#include<conio.h>
void main()
{
int n, i, sum = 0;
clrscr();
printf("Enter the limit : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
sum += i;
}
printf("Sum = %d", sum);
getch();
}


0 Comments