Programs C
Programs C
#include <stdio.h>
int main() {
char operator;
scanf("%c", &operator);
switch (operator) {
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
break;
default:
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
scanf("%d", &guess);
if(guess == randomNumber)
else
return 0;
}
Temperature Converter
int main() {
scanf("%f", &celsius);
return 0;
#include <stdio.h>
int main() {
int n, i, flag = 0;
scanf("%d", &n);
if(n % i == 0) {
flag = 1;
break;
if (n == 1) {
} else {
if (flag == 0)
else
return 0;
Fibonacci Sequence
#include <stdio.h>
int main() {
int i, n, t1 = 0, t2 = 1, nextTerm;
scanf("%d", &n);
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
return 0;
Palindrome Checker
#include <stdio.h>
#include <string.h>
int main() {
scanf("%s", str);
strcpy(rev, str);
strrev(rev);
if(strcmp(str, rev) == 0)
else
}
Palindrome Checker
#include <stdio.h>
#include <string.h>
int main() {
scanf("%s", str);
strcpy(rev, str);
strrev(rev);
if(strcmp(str, rev) == 0)
else
return 0;
Factorial Calculator
#include <stdio.h>
int main() {
int n, i;
scanf("%d", &n);
if (n < 0)
else {
factorial *= i;
return 0;
#include <stdio.h>
int main() {
int option;
do {
printf("ATM System\n");
printf("1. Deposit\n");
printf("2. Withdraw\n");
printf("3. Balance\n");
printf("4. Exit\n");
scanf("%d", &option);
switch(option) {
case 1:
scanf("%f", &deposit);
balance += deposit;
break;
case 2:
scanf("%f", &withdraw);
balance -= withdraw;
else
printf("Insufficient balance.\n");
break;
case 3:
break;
} while(option != 4);
return 0;
}
To-Do List
#include <stdio.h>
#include <string.h>
int main() {
char tasks[10][100];
int count = 0, i;
do {
if(strcmp(token, "done") != 0) {
strcpy(tasks[count], token);
count++;
printf("To-Do List:\n");
return 0;
}
Digital Clock
#include <stdio.h>
#include <time.h>
int main() {
time_t rawtime;
struct tm * timeinfo;
char buffer[80];
time(&rawtime);
timeinfo = localtime(&rawtime);
return 0;
#include <stdio.h>
int main() {
scanf("%f", &rate);
scanf("%f", &time);
return 0;
#include <stdio.h>
#define PI 3.14159
int main() {
scanf("%f", &radius);
return 0;
}
Program Name: Reverse a String
Function Used: printf, scanf, strlen
Code
#include <stdio.h>
#include <string.h>
int main() {
int i, j, len;
scanf("%s", str);
len = strlen(str);
rev[j] = str[i];
rev[j] = '\0';
return 0;
}
Program Name: Sum of Natural Numbers
#include <stdio.h>
int main() {
int n, sum = 0;
sum += i;
return 0;
}
Program Name: Multiplication Table
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
return 0;
1. }
o }
o
2. Program Name: Check Even or Odd
o Function Used: printf, scanf
#include <stdio.h>
int main() {
int num;
scanf("%d", &num);
if(num % 2 == 0)
else
return 0;
}
Program Name: Find ASCII Value of a Character
#include <stdio.h>
int main() {
char c;
scanf("%c", &c);
#include <stdio.h>
int main() {
int a, b, temp;
temp = a;
a = b;
b = temp;
return 0;
#include <stdio.h>
int main() {
int year;
printf("Enter a year: ");
scanf("%d", &year);
else
return 0;
#include <stdio.h>
int main() {
int a, b, c;
else
return 0;
}
#include <stdio.h>
#include <ctype.h>
int main() {
char str[100];
int count = 0;
scanf("%s", str);
char ch = tolower(str[i]);
++count;
return 0;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
return 0;
#include <stdio.h>
#include <math.h>
int main() {
scanf("%d", &num);
originalNum = num;
originalNum /= 10;
}
if ((int)result == num)
else
return 0;
}
Program Name: Binary to Decimal Conversion
#include <stdio.h>
#include <math.h>
int main() {
long long n;
scanf("%lld", &n);
while (n != 0) {
rem = n % 10;
n /= 10;
dec += rem * pow(2, i);
++i;
return 0;
#include <stdio.h>
#include <string.h>
int main() {
scanf("%s", s1);
scanf("%s", s2);
strcat(s1, s2);
return 0;
#include <stdio.h>
#include <string.h>
int main() {
char s[100];
scanf("%s", s);
return 0;
#include <stdio.h>
#include <math.h>
int main() {
scanf("%lf", &base);
scanf("%lf", &exp);
printf("Result: %.2lf", pow(base, exp));
return 0;
}
Program Name: Find the Largest Element in an Array
#include <stdio.h>
int main() {
scanf("%d", &n);
scanf("%d", &arr[i]);
max = arr[0];
max = arr[i];
return 0;
}
#include <stdio.h>
int main() {
int n, arr[1000];
scanf("%d", &n);
scanf("%d", &arr[i]);
sum += arr[i];
return 0;
}
Program Name: Count the Number of Digits in an Integer
#include <stdio.h>
int main() {
long long n;
int count = 0;
printf("Enter an integer: ");
scanf("%lld", &n);
while (n != 0) {
n /= 10;
++count;
return 0;