Series programs in C

 C Program to print the following series 1 2 3 4 ..... n.
```int main( ) {
int n, i;
printf("Enter Value for N : ");
scanf("%d", &n);
for(i=1; i<=n; i++) {
printf("%d ", i);
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N: 11
1 2 3 4 5 6 7 8 9 10 11```
 C Program to print the following series. 2 4 6 8 10 . . . . . . . n.
```#include<stdio.h>
int main( ) {
int n, i;
printf("Enter Value for N : ");
scanf("%d", &n);
for(i=1; i<=n; i++) {
if(n%2 == 0) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N: 15
2 4 6 8 10 12 14```
 C Program to print the following series. 1 3 5 7 9 .....n.
```#include<stdio.h>
int main( ) {
int n, i;
printf("Enter Value for N : ");
scanf("%d", &n);
for(i=1; i<=n; i++) {
if(n%2 != 0) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N: 15
1 3 5 7 9 11 13 15```
 C Program to print the following series. 3 6 9 12 15 ... n terms.
```#include<stdio.h>
int main( ){
int n, i, value;
printf("Enter Value for N : ");
scanf("%d", &n);
for(i=1; i<=n; i++) {
value = i*3;
printf("%d ", value);
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N: 10
3 6 9 12 15 18 21 24 27 30```
 C Program to print the following series. 1 3 7 15 31 . . . . . . . upto n times.
```#include<stdio.h>
#include<math.h>
int main( ) {
int n, i, value=0;
printf("Enter Value for N : ");
scanf("%d", &n);
for(i=0; i<=n; i++) {
value = value + pow(2, i);
printf("%d ", value);
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N: 6
1 3 7 15 31 63```
 C Program to print all prime numbers till 20.
```#include<stdio.h >
int main( ) {
int i, j, factors;
for(n=2; j<=20; n++) {
factors = 0;
for(i=1; i<=n ; i++) {
if(n%i == 0) {
factors++
}
}
if(factors == 2) {
printf("%d ",n);
}
}  return 0;
}```
OUTPUT :
`2 3 5 7 11 13 17 19`

 C Program to print the following febonnaci series 0 1 1 2 3 5 8 13 21 ... upto n times.
```#include<stdio.h>
int main( ){
int i, a,b,c;
printf("Enter Value for N : ");
scanf("%d", &n);
a = -1;
b = 1;
for(i=0; i < n; i++) {
c = a+b;
printf("%d ",c);
a = b;
b = c;
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter Value for N : 8
0 1 1 2 3 5 8 13```
 C Program to print to print the following series. 1 2 2 3 3 3 4 4 4 4.
```#include<stdio.h>
int main( ) {
int i,j;
for(i=1; i<=4; i++) {
for(j=1; j<=i; j++) {
printf("%d ",i);
}
}
printf("\n");
return 0;
}```
OUTPUT :
`1 2 2 3 3 3 4 4 4 4`
 C Program to print the following series. 0 1 3 6 10 15 21 upto n terms.
```#include<stdio.h>
int main( ) {
int n,i,j=0;
printf("Enter a value for N : ");
scanf("%d",&n);
for(i = 1; i<=n; i++) {
printf("%d ",j);
j = j+i;
}
printf("\n");
return 0;
}```
OUTPUT :
```Enter a value for N : 8
0 1 3 6 10 15 21 28```

#### CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824