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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
source,target
|
2 |
+
"#include <stdio.h>
|
3 |
+
int main() {
|
4 |
+
printf(""Hello, world!\n"");
|
5 |
+
return 0;
|
6 |
+
}","A simple C program that prints 'Hello, world!' to the console."
|
7 |
+
"#include <stdio.h>
|
8 |
+
|
9 |
+
int factorial(int n) {
|
10 |
+
if (n == 0)
|
11 |
+
return 1;
|
12 |
+
else
|
13 |
+
return n * factorial(n - 1);
|
14 |
+
}
|
15 |
+
|
16 |
+
int main() {
|
17 |
+
int n = 5;
|
18 |
+
printf(""Factorial of %d is %d\n"", n, factorial(n));
|
19 |
+
return 0;
|
20 |
+
}",A C program to calculate the factorial of a number using recursion.
|
21 |
+
"#include <stdio.h>
|
22 |
+
|
23 |
+
int main() {
|
24 |
+
int n, sum = 0;
|
25 |
+
printf(""Enter a number: "");
|
26 |
+
scanf(""%d"", &n);
|
27 |
+
for (int i = 1; i <= n; i++) {
|
28 |
+
sum += i;
|
29 |
+
}
|
30 |
+
printf(""Sum of first %d natural numbers is %d\n"", n, sum);
|
31 |
+
return 0;
|
32 |
+
}",A C program to calculate the sum of the first 'n' natural numbers.
|
33 |
+
"#include <stdio.h>
|
34 |
+
|
35 |
+
int main() {
|
36 |
+
double a, b, product;
|
37 |
+
printf(""Enter two numbers: "");
|
38 |
+
scanf(""%lf %lf"", &a, &b);
|
39 |
+
product = a * b;
|
40 |
+
printf(""Product = %.2lf"", product);
|
41 |
+
return 0; }",A C Program to Multiply Two Numbers
|
42 |
+
"#include <stdio.h>
|
43 |
+
|
44 |
+
int main() {
|
45 |
+
|
46 |
+
printf(""Hello, World!"");
|
47 |
+
|
48 |
+
return 0;
|
49 |
+
}","Program to Display Hello, World!"
|
50 |
+
"#include <stdio.h>
|
51 |
+
|
52 |
+
int main() {
|
53 |
+
|
54 |
+
int number;
|
55 |
+
|
56 |
+
printf(""Enter an integer:"");
|
57 |
+
|
58 |
+
scanf(""%d"", &number);
|
59 |
+
|
60 |
+
printf(""You entered: %d"", number);
|
61 |
+
|
62 |
+
return 0;}",A C Program to Print an Integer
|
63 |
+
"#include <stdio.h>
|
64 |
+
|
65 |
+
int main() {
|
66 |
+
|
67 |
+
int number;
|
68 |
+
|
69 |
+
printf(""Enter an integer:""); scanf(""%d"", &number);
|
70 |
+
// displays output
|
71 |
+
printf(""You entered: %d"", number);
|
72 |
+
|
73 |
+
return 0; }", A Program to Print an Integer
|
74 |
+
"#include <stdio.h>
|
75 |
+
|
76 |
+
int main() {
|
77 |
+
|
78 |
+
char c;
|
79 |
+
|
80 |
+
printf(""Enter a character:"");
|
81 |
+
|
82 |
+
scanf(""%c"", &c);
|
83 |
+
|
84 |
+
// %d displays the integer value of a character
|
85 |
+
|
86 |
+
// %c displays the actual character
|
87 |
+
|
88 |
+
printf(""ASCII value of %c = %d"", c, c);
|
89 |
+
|
90 |
+
return 0; }",A Program to Print SCII Value
|
91 |
+
"#include <stdio.h>
|
92 |
+
|
93 |
+
int main() {
|
94 |
+
|
95 |
+
int dividend, divisor, quotient, remainder;
|
96 |
+
|
97 |
+
printf(""Enter dividend:"");
|
98 |
+
|
99 |
+
printf(""Enter divisor:"");
|
100 |
+
|
101 |
+
scanf(""%d"", ÷nd);
|
102 |
+
|
103 |
+
scanf(""%d"", &divisor);
|
104 |
+
|
105 |
+
// Computes quotient
|
106 |
+
|
107 |
+
quotient = dividend / divisor;
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
// Computes remainder
|
112 |
+
|
113 |
+
remainder = dividend % divisor;
|
114 |
+
|
115 |
+
printf(""Quotient = %d
|
116 |
+
"", quotient);
|
117 |
+
|
118 |
+
return 0;
|
119 |
+
|
120 |
+
}",C Program to Compute Quotient and Remainder
|
121 |
+
" #include<stdio.h>
|
122 |
+
|
123 |
+
int main() {
|
124 |
+
|
125 |
+
int intType;
|
126 |
+
|
127 |
+
float floatType;
|
128 |
+
|
129 |
+
double doubleType;
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
char charType;
|
134 |
+
|
135 |
+
// sizeof evaluates the size of a variable
|
136 |
+
|
137 |
+
printf(""Size of int: %zu bytes
|
138 |
+
"", sizeof(intType));
|
139 |
+
|
140 |
+
printf(""Size of float: %zu bytes
|
141 |
+
"", sizeof(floatType));
|
142 |
+
|
143 |
+
printf(""Size of double: %zu bytes
|
144 |
+
"", sizeof(doubleType));
|
145 |
+
|
146 |
+
printf(""Size of char: %zu byte
|
147 |
+
"", sizeof(charType));
|
148 |
+
|
149 |
+
return 0; }","C Program to Find the Size of int, float, double and char"
|
150 |
+
"#include <stdio.h>
|
151 |
+
|
152 |
+
int main() {
|
153 |
+
|
154 |
+
int a;
|
155 |
+
|
156 |
+
long b; // equivalent to long int b;
|
157 |
+
|
158 |
+
long long c; // equivalent to long long int c;
|
159 |
+
|
160 |
+
double e;
|
161 |
+
|
162 |
+
long double f;
|
163 |
+
|
164 |
+
printf(""Size of int = %zu bytes
|
165 |
+
"", sizeof(a));
|
166 |
+
|
167 |
+
printf(""Size of long int = %zu bytes
|
168 |
+
"", sizeof(b));
|
169 |
+
|
170 |
+
printf(""Size of long long int = %zu bytes
|
171 |
+
"", sizeof(c));
|
172 |
+
|
173 |
+
printf(""Size of double = %zu bytes
|
174 |
+
"", sizeof(e));
|
175 |
+
|
176 |
+
printf(""Size of long double = %zu bytes
|
177 |
+
"", sizeof(f));
|
178 |
+
|
179 |
+
return 0;
|
180 |
+
|
181 |
+
}",C Program to Demonstrate the Working of Keyword long
|
182 |
+
"#include<stdio.h>
|
183 |
+
|
184 |
+
int main() {
|
185 |
+
|
186 |
+
double first, second, temp;
|
187 |
+
|
188 |
+
printf(""Enter first number:"");
|
189 |
+
|
190 |
+
scanf(""%lf"", &first);
|
191 |
+
|
192 |
+
printf(""Enter second number: "");
|
193 |
+
|
194 |
+
scanf(""%lf"", &second);
|
195 |
+
|
196 |
+
// value of first is assigned to temp
|
197 |
+
|
198 |
+
temp = first;
|
199 |
+
|
200 |
+
// value of second is assigned to first
|
201 |
+
|
202 |
+
first = second;
|
203 |
+
|
204 |
+
// value of temp (initial value of first) is assigned to second
|
205 |
+
|
206 |
+
second = temp;
|
207 |
+
|
208 |
+
// %.2lf displays number up to 2 decimal points
|
209 |
+
|
210 |
+
printf(""
|
211 |
+
After swapping, first number = %.2lf
|
212 |
+
"", first);
|
213 |
+
|
214 |
+
printf(""After swapping, second number = %.2lf"", second);
|
215 |
+
|
216 |
+
return 0; }",C Program to Swap Two Numbers
|
217 |
+
" #include <stdio.h>
|
218 |
+
|
219 |
+
int main() {
|
220 |
+
|
221 |
+
int num;
|
222 |
+
|
223 |
+
printf(""Enter an integer: "");
|
224 |
+
|
225 |
+
scanf(""%d"", &num);
|
226 |
+
|
227 |
+
// true if num is perfectly divisible by 2
|
228 |
+
|
229 |
+
if(num % 2 == 0)
|
230 |
+
|
231 |
+
printf(""%d is even."", num);
|
232 |
+
|
233 |
+
else
|
234 |
+
|
235 |
+
printf(""%d is odd."", num);
|
236 |
+
|
237 |
+
return 0; }",C Program to Check Whether a Number is Even or Odd
|
238 |
+
"#include <stdio.h>
|
239 |
+
|
240 |
+
int main() {
|
241 |
+
|
242 |
+
char c;
|
243 |
+
|
244 |
+
int lowercase_vowel, uppercase_vowel;
|
245 |
+
|
246 |
+
printf(""Enter an alphabet:"");
|
247 |
+
|
248 |
+
scanf(""%c"", &c);
|
249 |
+
|
250 |
+
// evaluates to 1 if variable c is a lowercase vowel
|
251 |
+
|
252 |
+
lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
|
253 |
+
|
254 |
+
// evaluates to 1 if variable c is a uppercase vowel
|
255 |
+
|
256 |
+
uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
|
257 |
+
|
258 |
+
// evaluates to 1 (true) if c is a vowel
|
259 |
+
|
260 |
+
if (lowercase_vowel || uppercase_vowel)
|
261 |
+
|
262 |
+
printf(""%c is a vowel."", c);
|
263 |
+
|
264 |
+
else
|
265 |
+
|
266 |
+
printf(""%c is a consonant."", c);
|
267 |
+
|
268 |
+
return 0;}", C Program to Check Whether a Character is a Vowel or Consonant
|
269 |
+
" #include <stdio.h>
|
270 |
+
|
271 |
+
int main() {
|
272 |
+
|
273 |
+
double n1, n2, n3;
|
274 |
+
|
275 |
+
printf(""Enter three different numbers: "");
|
276 |
+
|
277 |
+
scanf(""%lf %lf %lf"", &n1, &n2, &n3);
|
278 |
+
|
279 |
+
// if n1 is greater than both n2 and n3, n1 is the largest
|
280 |
+
|
281 |
+
if(n1 >= n2 && n1 >= n3)
|
282 |
+
|
283 |
+
printf(""%.2f is the largest number."", n1);
|
284 |
+
|
285 |
+
// if n2 is greater than both n1 and n3, n2 is the largest
|
286 |
+
|
287 |
+
if (n2 >= n1 && n2 >= n3)
|
288 |
+
|
289 |
+
printf(""%.2f is the largest number."", n2);
|
290 |
+
|
291 |
+
// if n3 is greater than both n1 and n2, n3 is the largest
|
292 |
+
|
293 |
+
if (n3 >= n1 && n3 >= n2)
|
294 |
+
|
295 |
+
printf(""%.2f is the largest number."", n3);
|
296 |
+
|
297 |
+
return 0;}",C Program to Find the Largest Number Among Three Numbers usinf if statement
|
298 |
+
"#include <stdio.h>
|
299 |
+
|
300 |
+
int main() {
|
301 |
+
|
302 |
+
double n1, n2, n3;
|
303 |
+
|
304 |
+
printf(""Enter three different numbers:"");
|
305 |
+
|
306 |
+
scanf(""%lf %lf %lf"", &n1, &n2, &n3);
|
307 |
+
|
308 |
+
// if n1 is greater than both n2 and n3, n1 is the largest
|
309 |
+
|
310 |
+
if (n1 >= n2 && n1 >= n3)
|
311 |
+
|
312 |
+
printf(""%.2f is the largest number."", n1);
|
313 |
+
|
314 |
+
// if n2 is greater than both n1 and n3, n2 is the largest
|
315 |
+
|
316 |
+
if (n2 >= n1 && n2 >= n3)
|
317 |
+
|
318 |
+
printf(""%.2f is the largest number."", n2);
|
319 |
+
|
320 |
+
// if n3 is greater than both n1 and n2, n3 is the largest
|
321 |
+
|
322 |
+
if (n3 >= n1 && n3 >= n2)
|
323 |
+
|
324 |
+
printf(""%.2f is the largest number."", n3);
|
325 |
+
|
326 |
+
return 0; } ",C Program to Find the Largest Number Among Three Numbers using if else statements
|
327 |
+
"#include <math.h>
|
328 |
+
|
329 |
+
#include <stdio.h>
|
330 |
+
|
331 |
+
int main() {
|
332 |
+
|
333 |
+
double a, b, c, discriminant, root1, root2, realPart, imagPart;
|
334 |
+
|
335 |
+
printf(""Enter coefficients a, b and c:"");
|
336 |
+
|
337 |
+
scanf(""%lf %lf %lf"", &a, &b, &c);
|
338 |
+
|
339 |
+
discriminant = b * b - 4 * a * c;
|
340 |
+
|
341 |
+
// condition for real and different roots
|
342 |
+
|
343 |
+
if (discriminant > 0) {
|
344 |
+
|
345 |
+
root1 = (-b + sqrt(discriminant)) / (2 * a);
|
346 |
+
|
347 |
+
root2 = (-b - sqrt(discriminant)) / (2 * a);
|
348 |
+
|
349 |
+
printf(""root1 = %.2lf and root2 = %.2lf"", root1, root2);
|
350 |
+
|
351 |
+
}
|
352 |
+
|
353 |
+
// condition for real and equal roots
|
354 |
+
|
355 |
+
else if (discriminant == 0) {
|
356 |
+
|
357 |
+
root1 = root2 = -b / (2 * a);
|
358 |
+
|
359 |
+
printf(""root1 = root2 = %.2lf;"", root1);
|
360 |
+
|
361 |
+
}
|
362 |
+
|
363 |
+
// if roots are not real
|
364 |
+
|
365 |
+
else {
|
366 |
+
|
367 |
+
realPart = -b / (2 * a);
|
368 |
+
|
369 |
+
imagPart = sqrt(-discriminant) / (2 * a);
|
370 |
+
|
371 |
+
printf(""root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi"", realPart, imagPart, realPart, imagPart);
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
return 0;
|
376 |
+
|
377 |
+
} ",C Program to Find the Roots of a Quadratic Equation
|
378 |
+
" #include <stdio.h>
|
379 |
+
|
380 |
+
int main() {
|
381 |
+
|
382 |
+
double n1, n2, n3;
|
383 |
+
|
384 |
+
printf(""Enter three numbers:"");
|
385 |
+
|
386 |
+
scanf(""%lf %lf %lf"", &n1, &n2, &n3);
|
387 |
+
|
388 |
+
// outer if statement
|
389 |
+
|
390 |
+
if (n1 >= n2) {
|
391 |
+
|
392 |
+
// inner if...else
|
393 |
+
|
394 |
+
if (n1 >= n3)
|
395 |
+
|
396 |
+
printf(""%.2lf is the largest number."", n1);
|
397 |
+
|
398 |
+
else
|
399 |
+
|
400 |
+
printf(""%.2lf is the largest number."", n3);
|
401 |
+
|
402 |
+
}
|
403 |
+
|
404 |
+
// outer else statement
|
405 |
+
|
406 |
+
else {
|
407 |
+
|
408 |
+
// inner if...else
|
409 |
+
|
410 |
+
if (n2 >= n3)
|
411 |
+
|
412 |
+
printf(""%.2lf is the largest number."", n2);
|
413 |
+
|
414 |
+
else
|
415 |
+
|
416 |
+
printf(""%.2lf is the largest number."", n3);
|
417 |
+
|
418 |
+
}
|
419 |
+
|
420 |
+
return 0;}", C Program to Find the Largest Number Among Three Numbers using nested if statement
|
421 |
+
"#include <stdio.h>
|
422 |
+
|
423 |
+
int main() {
|
424 |
+
|
425 |
+
int year;
|
426 |
+
|
427 |
+
printf(""Enter a year:"");
|
428 |
+
|
429 |
+
scanf(""%d"", &year);
|
430 |
+
|
431 |
+
// leap year if perfectly divisible by 400
|
432 |
+
|
433 |
+
if (year % 400 == 0) {
|
434 |
+
|
435 |
+
printf(""%d is a leap year."", year);
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
// not a leap year if divisible by 100
|
440 |
+
|
441 |
+
// but not divisible by 400
|
442 |
+
|
443 |
+
else if (year % 100 == 0) {
|
444 |
+
|
445 |
+
printf(""%d is not a leap year."", year);
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
// leap year if not divisible by 100
|
450 |
+
|
451 |
+
// but divisible by 4
|
452 |
+
|
453 |
+
else if (year % 4 == 0) {
|
454 |
+
|
455 |
+
printf(""%d is a leap year."", year);
|
456 |
+
|
457 |
+
}
|
458 |
+
|
459 |
+
// all other years are not leap years
|
460 |
+
|
461 |
+
else {
|
462 |
+
|
463 |
+
printf(""%d is not a leap year."", year);
|
464 |
+
|
465 |
+
}
|
466 |
+
|
467 |
+
return 0; } ",C Program to Check Leap Year
|
468 |
+
"#include <stdio.h>
|
469 |
+
|
470 |
+
int main() {
|
471 |
+
|
472 |
+
double num;
|
473 |
+
|
474 |
+
printf(""Enter a number:"");
|
475 |
+
|
476 |
+
scanf(""%lf"", &num);
|
477 |
+
|
478 |
+
if (num <= 0.0) {
|
479 |
+
|
480 |
+
if (num == 0.0)
|
481 |
+
|
482 |
+
printf(""You entered 0."");
|
483 |
+
|
484 |
+
else
|
485 |
+
|
486 |
+
printf(""You entered a negative number."");
|
487 |
+
|
488 |
+
}
|
489 |
+
|
490 |
+
else
|
491 |
+
|
492 |
+
printf(""You entered a positive number."");
|
493 |
+
|
494 |
+
return 0;
|
495 |
+
|
496 |
+
}", C Program to Check Whether a Number is Positive or Negative
|
497 |
+
"#include <stdio.h>
|
498 |
+
|
499 |
+
int main() {
|
500 |
+
|
501 |
+
char c;
|
502 |
+
|
503 |
+
printf(""Enter a character:"");
|
504 |
+
|
505 |
+
scanf(""%c"", &c);
|
506 |
+
|
507 |
+
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
508 |
+
|
509 |
+
printf(""%c is an alphabet."", c);
|
510 |
+
|
511 |
+
else
|
512 |
+
|
513 |
+
printf(""%c is not an alphabet."", c);
|
514 |
+
|
515 |
+
return 0;}", C Program to Check Whether a Character is an Alphabet or not
|