C Programming Examples
C Programming Examples
int main() {
printf(“Hello, World!\n”);
return 0;
int main() {
printf(“Your Name\n”);
return 0;
#include <stdio.h>
int main() {
scanf("%d", &num);
} else {
if (num % i == 0) {
break;
if (isPrime) {
} else {
return 0;
return 0;
}
5. C Program to Print the ASCII Value of a Character
#include <stdio.h>
int main() {
char character;
return 0;
}
6. C Program to Swap Two Numbers
#include <stdio.h>
int main() {
int num1, num2, temp;
return 0;
}
7. C Program to Calculate Fahrenheit to Celsius
#include <stdio.h>
int main() {
float fahrenheit, celsius;
// Input temperature in Fahrenheit
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &fahrenheit);
return 0;
}
// If i is prime, print it
if (isPrime)
printf("%d ", i);
}
return 0;
}
9. C Program to Check Whether a Number is Positive, Negative, or Zero
#include <stdio.h>
int main() {
int num;
// Input the number
printf("Enter a number: ");
scanf("%d", &num);
return 0;
}
12.C Program to Print Alphabets From A to Z Using Loop
#include <stdio.h>
int main() {
char ch;
int main() {
float principal, rate, time, interest;
return 0;
}
14.C Program to Check Armstrong Number:
#include <stdio.h>
int main() {
int num, temp, remainder, sum = 0;
// Input from user
printf("Enter a number: ");
scanf("%d", &num);
temp = num;
// Calculate the sum of the cubes of the digits
while (temp != 0) {
remainder = temp % 10;
sum += remainder * remainder * remainder; // Cube of the digit
temp /= 10;
}
// Check if the sum is equal to the original number
if (sum == num) {
printf("%d is an Armstrong number.\n", num);
} else {
printf("%d is not an Armstrong number.\n", num);
}
return 0;
}
15.Program to find the largest number among three numbers
#include <stdio.h>
int main() {
int num1, num2, num3;
// Taking input from the user
printf("Enter three numbers: ");
scanf("%d %d %d", &num1, &num2, &num3);
// Compare the numbers to find the largest
if (num1 >= num2 && num1 >= num3) {
printf("%d is the largest number.\n", num1);
}
else if (num2 >= num1 && num2 >= num3) {
printf("%d is the largest number.\n", num2);
}
else {
printf("%d is the largest number.\n", num3);
}
return 0;
}