C program to convert decimal number to binary number

Here you will get C program to print first n natural numbers and their sum.

Program

#include<stdio.h>
 
int main()
{
	int n,i,sum=0;
	printf("Enter the value of n:");
	scanf("%d",&n);
	
	for(i=1;i<=n;++i)
	{
		printf("\n%d",i);
		sum+=i;
	}
	
	printf("\n\nSum of first n natural numbers is:%d",sum);
 
	return 0;
}

Output

Enter the value of n:7

1
2
3
4
5
6
7

Sum of first n natural numbers is:28

DURGESH

I Love python, so I like machine learning a Lot and on the other hand, I like building apps and fun games I post blogs on my website for Tech enthusiast to learn and Share Information With The World.

Leave a Reply

Your email address will not be published. Required fields are marked *

six − three =

Recent Content