-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassignment5.c
177 lines (158 loc) · 2.8 KB
/
assignment5.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
// Online C compiler to run C program online
//WRITE A PROGRAM TO PRINT MySirG N times on the screen
/*#include <stdio.h>
int main() {
int n;
printf("enter number");
scanf("%d",&n);
while(n>0)
{
printf("MySirG\n");
n--;
}
return 0;
}*/
//WRITE A PROGRAM TO PRINT THE FIRST N NATURAL NUMBER......
/*#include <stdio.h>
int main() {
int n,i=1;
printf("enter number");
scanf("%d",&n);
do
{
printf("%d ",i);
i++;
}while(n>=i);
return 0;
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(i<=n)
{
printf("%d ",i);
i++;
}
return 0;
}*/
///WRITE A PROGRAM TO PRINT THE FIRST N NATURAL NUMBER in reverse order
/*#include <stdio.h>
int main()
{
int n,i=0;
printf("enter number");
scanf("%d",&n);
while(n)
{
printf("%d ",n);
n--;
}
return 0;
return 0;
}*/
//4. Write a program to print the first N odd natural numbers
/*#include <stdio.h>
int main()
{
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(n*2>i)
{
printf("%d ",i);
i=i+2;
}
return 0;
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(i<=n)
{
printf("%d ",i);
i=i+2;
}
}*/
//5. . Write a program to print the first N odd natural numbers in reverse order.
/*#include <stdio.h>
int main()
{
int n;
printf("enter number");
scanf("%d",&n);
if(n%2)
{}
else
n--;
while(n>0)
{
printf("%d ",n);
n=n-2;
}
return 0;
}*/
//6 Write a program to print the first N even natural numbers
/*#include <stdio.h>
int main()
{
int n,i=1;
printf("enter number");
scanf("%d",&n);
for(int i=1;i<=n/2;i++)
{
printf("%d",i*2);
}
return 0;
}*/
//7 Write a program to print the first N even natural numbers in reverse order
/*#include <stdio.h>
int main()
{
int n;
printf("enter number");
scanf("%d",&n);
for(int i=n/2;i>=1;i--)
{
printf("%d",i*2);
}
}*/
//8 Write a program to print squares of the first N natural numbers
/*#include <stdio.h>
int main()
{
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(n>=i)
{
printf("%d ",i*i);
i++;
}
return 0;
}*/
//9....... Write a program to print cubes of the first N natural numbers
/*#include <stdio.h>
int main()
{
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(n>=i)
{
printf("%d ",i*i*i);
i++;
}
return 0;
}*/
//10.......writea program to print table of n
/*#include <stdio.h>
int main()
{
int n,i=1;
printf("enter number");
scanf("%d",&n);
while(10>=i)
{
printf(" %d * %d = %d\n ",n ,i,n*i);
i++;
}
return 0;
}*/