-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment7.c
212 lines (204 loc) · 3.96 KB
/
assignment7.c
1
2
3
4
5
6
7
8
9
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//1.write a program to find the n th term of fibonaci series
/*#include<stdio.h>
int main()
{
int a=0,b=1,c,n;
printf("enter number");
scanf("%d",&n);//5
while(a<=n)
{
printf("%d ",a);
c=a+b;
a=b;
b=c;
}
return 0;
}*/
//Write a program to print first N terms of Fibonacci series
/*#include<stdio.h>
int main()
{
int a=0,b=1,c,n;
printf("enter number");
scanf("%d",&n);
while(n)
{
printf("%d ",a);
c=a+b;
a=b;
b=c;
n--;
}
return 0;
}*/
//3.write a program to check whether a given number is there in the fibonacci series or not
/*#include<stdio.h>
#include<stdlib.h>
int main()
{
int a=0,b=1,c,n;
printf("enter number");
scanf("%d",&n);
while(a<=n)
{
if(a==n)
{
printf("present in fibonacci series");
exit(0);
}
c=a+b;
a=b;
b=c;
}
printf("does not present in fibonacci series");
}*/
//write a program to calculate HCF of two number.....
/*#include<stdio.h>
int main()
{
int a,b,i,max,HCF=1;
printf("enter number");
scanf("%d %d",&a,&b);
max=a>b?a:b;
for(i=1;i<=max/2;i++)
{
if(a%i==0&& b%i==0)
HCF=i;
}
printf("HCF of %d and %d are %d",a,b,HCF);
}*/
//write a program to check whether two given numbers are co-prime number or not
/*#include<stdio.h>
int main()
{
int a,b,max,i,k=0;
printf("enter number");
scanf("%d %d",&a,&b);
max=a>b?a:b;
for(i=2;i<=max/2;i++)
{
if(a%i==0 && b%i==0)
{
k++;
break;
}
}
if(k==1)
printf("number are a not co -prime");
else
printf("number are co-prime");
}*/
//writea program to print all prime number under 100
/*#include<stdio.h>
int main()
{
int i,k,c=0;
for(i=1;i<=100;i++)
{
for(k=2;k<=i/2;k++)
{
if(i%k==0)
{
c++;
break;
}
}
if(c==0 && i!=1)
{
printf("%d ",i);
}
}
return 0;
}*/
//7.write a program to print all prime number between two given numbers
/*#include<stdio.h>
int main()
{
int a,b,c,k,n;
printf("enter lower number");
scanf(" %d",&a);
printf("\nenter upper number");
scanf(" %d",&b);
for(n=a+1;n<b;n++)
{
c=0;
for(k=2;k<=n/2;k++)
{
if(n%k==0)
{
c++;
break;
}
}
if(c==0 && n!=1)
{
printf("%d ",n);
}
}
return 0;
}*/
//8.write a program to find next prime number of a given number....
/*#include<stdio.h>
int main()
{
int a,i,j,c;
printf("enter number");
scanf("%d",&a);
for(i=a+1;i<=i+4;i++)
{
c=0;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
c++;
break;
}
}
if(c==0)
{
printf("%d ",i);
break;
}
}
return 0;
}*/
//9.write a program to check whether a given number is an Armstrong number or not
/*#include<stdio.h>
int main()
{
int n,modulo,num=0,copyn;
printf("enter number");
scanf("%d",&n);
copyn=n;
while(n)
{
modulo=n%10;
num=(modulo*modulo*modulo)+num;
n=n/10;
}
copyn==num?printf("number is armstrong number"):printf("number is not armstrong");
return 0;
}*/
//10.write a program to print all armstrong numbers under 1000
/*#include<stdio.h>
int main()
{
int modulo,n,num,copyn,i;
for(i=0;i<=1000;i++)
{
n=i;
num=0;
while(n>0)
{
modulo=n%10;
num=(modulo*modulo*modulo)+num;
n=n/10;
}
if(i==num)
{
printf("%d ",i);
}
}
return 0;
}*/