## C C++ program to generate series of natural numbers and find sum

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

### Flowchart program to generate series of natural numbers and find sum

### C program to generate series of natural numbers and find sum

```
#include<stdio.h>
int main()
{
int num=1,n,sum=0;
printf("Enter n: ");
scanf("%d",&n);
while(num<=n)
{
printf("%d\n",num);
sum=sum+num;
num++;
}
printf("Sum of series = %d",sum);
return 0;
}
```

### C++ program to generate series of natural numbers and find sum

```
#include<iostream>
using namespace std;
int main()
{
int num=1,n,sum=0;
cout<<"Enter n: ";
cin>>n;
while(num<=n)
{
cout<<num<<"\n";
sum=sum+num;
num++;
}
cout<<"Sum of series = "<<sum;
return 0;
}
```

### Output of C C++ program to generate series of natural numbers and find sum

Enter n: 5 1 2 3 4 5 Sum of series = 15

Enter n: 10 1 2 3 4 5 6 7 8 9 10 Sum of series = 55

### Other Iterative logic programs in C C++

- Generate series of natural numbers (while, for, do while)
- Generate series of odd numbers and find their sum
- Generate series of even numbers and find their sum
- Generate table of given number
- Find factorial of given number
- Find power of given number
- Generate multiplication table of given number
- HCF and LCM of two numbers
- Generating Fibonacci series
- Checking prime number
- Generating series of prime numbers
- Sum of digits of given number
- Reverse of digits of given number
- Checking palindrome number
- Checking Armstrong number
- Generating series of Armstrong numbers
- Convert decimal to binary
- Convert binary to decimal