Document 5
Document 5
1.PRINT 1 TO 100
INPUT;#include<stdio.h>
int main()
{for(int i=1;i<=100;i+=1)
{printf("%d\n",i);}
return 0;}
OUTPUT;dent@OptiPlex-3000-16:~$ ./a.out
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100.
INPUT;#include<stdio.h>
int main()
{for(int i=2;i<=100;i+=2)
{printf("%d\n",i);}
return 0;}
OUTPUT;2
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100.
INPUT;#include<stdio.h>
int num=6;
int i;
for(i<=1;i<=10;i++)
{printf("%d*%d=%d\n",i,num,i*num);}
return 0;}
OUTPUT;0*6=0
1*6=6
2*6=12
3*6=18
4*6=24
5*6=30
6*6=36
7*6=42
8*6=48
9*6=54
10*6=60
INPUT;#include<stdio.h>
int num=6;
int i;
for(i=1;i<=6;++i)
if(num%i==0)
{printf("%d\n",i);}}
OUTPUT;1
INPUT;#include<stdio.h>
int n;
printf("enter the number for factorial\n");
scanf("%d",&n);
printf("factorial of %d is",n);
int a=1;
for(int i=1;i<=n;i++)
{a=a*i;}
printf("%d",a);
return 0;}
factorial of 6 is720.
INPUT;#include<stdio.h>
void main()
{int l,i,j,s;
printf("enter a number:");
scanf("%d",&i);
s=0;
l=i;
j=i%10;
for(j;i!=0;j=i%10)
{s=s+j;
i=i/10;}
printf("sum of digits of %d is %d",l,s);}
output;enter a number:123
int main()
{int i,x,n,sum;
scanf("%d",&x);
sum=0;
int z =x;
while (x!=0)
{n=x%10;
sum =(sum*10)+n;
x=x%10;}
if(z==sum)
else
return 0;}
ans)input;#include<stdio.h>
int main()
{int i,j;
printf("enter a number:");
scanf("%d",&i);
j=i-1;
for (j;j>=1;j--)
{if(j==1)
{printf("%d is a prime",i);
break;}
else if(i%j==0)
break;};}
5 is a prime.
INPUT;#include<stdio.h>
int i,j;
scanf("%d,%d",&i,&j);
int k=i-1;
for(;i<=j;++i)
{k=i-1;
while(k>1)
if(i%k==0)
{printf("\n");
break;}
--k
if(k==1)
{printf("%d is a prime\n",i);}
return 0;}
3 IS PRIME NUMBER
5 IS PRIME NUMBER
7 IS PRIME NUMBER
#include<stdio.h>
void main()
{int i,j,k;
scanf("%d,%d",&i,&j);
k=i;
for(i;i<=j;i=i+k)
{k=i-k;
printf("%d,",i);};}
output;
1,1,2,3,5,
ans); input;
#include<stdio.h>
void main()
{int n,k,j;
printf("enter a number:");
scanf("%d",&n);
j=n;
k=0;
for(n;n>0;n--)
{k=k+n;
if(n==1)
output;
enter a number:5
Ans)input;
include<stdio.h>
void main()
{int i,j,k,s=0,t=0;
printf("enter a number:");
scanf("%d",&i);
t=t+i;
for(i;i/10>=0;i=i/10)
{ k=1;
for(j=i%10;j>0;j--)
{k*=j;}
s=s+k;
if(i/10==0)
break;
}
if(s==t)
else
out put)
enter a number:1
output:/tmp/dlqqglpE0g.o
enter a number:1
#include <math.h>
int main() {
scanf("%d", &n);
N = n;
int numberOfDigits = 0;
while (N != 0) {
N = N / 10;
++numberOfDigits;
}
N = n;
while (N != 0) {
remainder = N % 10;
N = N / 10;
if (result == n)
else
return 0;
int main()
{float n,b=1,i,k,a=1,t;
printf("enter the value of n and till wher you need the series");
scanf("%f%f",&n,&t);
k=n;
for(i=1;i<=t;i++)
{n=n*k/(b+1);
a=a+n;
b++;}
output;
enter the value of n and till wher you need the series3
300
input;#include<stdio.h>
int main()
{float a=0,c=1,x,b,n,i;
printf("enter the value of number u wnat and series till where u want");
scanf("%f%f",&x,&n);
b=x;
for(i=1;i<=n;i++)
{a=a+b;
b=(-1*x*x*b)/((c+1)*(c+2));
c=c+2;}
printf("%f",a);}
output;
enter the value of number u wnat and series till where u want3
100
0.141120.