Q.1 Write a C program to find the sum of all natural numbers between 1 to n.
Program - 1
Write a C program to find the sum of all natural numbers between 1 to n.
Solution :-
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,n,sum=0;
printf(“Enter the number :- “);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
sum = sum + i;
}
printf(“The sum of n natual number is :- %d”,sum);
getch();
}
Write a C program to find the sum of all natural numbers between 1 to n.FlowChart
Solution :-

Write a C program to find the sum of all natural numbers between 1 to n.(Algorithm)
Solution :-
Step 1 :- Start
Step 2 :- Initialize variables: n, sum = 0.
Step 3 :- Read the value of n from the user.
Step 4 :- Initialize a loop from i = 1 to n.
Step 5 :- In each iteration of the loop, add i to sum.
Step 6 :- After the loop, sum will contain the sum of all natural numbers from 1 to n.
Step 7 :- Display the value of sum.
Step 8 :- End.

Fun & Easy to follow

Works on all devices

Your own Pace

Super Affordable
Popular Videos

UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer

SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.

Chris Matthews
Designer