0% found this document useful (0 votes)
30 views9 pages

Static Questions

The document contains the code for 6 programs. The programs include calculating grades from marks, a basic calculator, Fibonacci series, checking palindromes, finding the sum of digits of a number squared, and calculating the sum of odd numbers between two numbers.

Uploaded by

kanhaprasad528
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views9 pages

Static Questions

The document contains the code for 6 programs. The programs include calculating grades from marks, a basic calculator, Fibonacci series, checking palindromes, finding the sum of digits of a number squared, and calculating the sum of odd numbers between two numbers.

Uploaded by

kanhaprasad528
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

#include <stdio.

h>

int main() {

int mark;

scanf("%d", &mark);

if (mark >= 90 & mark <= 100) {

printf("Grade: A");

else if (mark >= 80 && mark <= 89) {

printf("Grade: B");

else if (mark >= 70 && mark <= 79) {

printf("Grade: C");

else if (mark >= 60 && mark <= 69) {

printf("Grade: D");

else if (mark >= 45 && mark <= 59) {

printf("Grade: E");

else if (mark >= 0 && mark < 45){

printf("Grade: F");

else{

printf("Invalid input");

return 0;

}
#include <stdio.h>

int main() {
int num1, num2;
int result;
char ch;

scanf("%d", &num1);
scanf("%d", &num2);
scanf(" %c", &ch);

result = 0;

switch(ch) {
case '+':
result = num1 + num2;
break;

case '-':
result = num1 - num2;
break;

case '*':
result = num1 * num2;
break;

default:
printf("INVALID");
return 0;
}

printf("%d", result);
return 0;
}
#include <stdio.h>

int main() {
int N;
int prev = 0, current = 1, next, i = 1;
scanf("%d", &N);

while (i <= N) {
printf("%d ", prev);
next = prev + current;
prev = current;
current = next;
i++;
}
return 0;
}
#include <stdio.h>
int main() {
int n, rev=0,r,no;

scanf("%d", &n);
no = n;
while (n>0) {
r = n % 10;
rev = rev * 10 + r;
n /= 10;
}
if (no == rev)
printf("Palindrome");
else
printf("Not a Palindrome");
return 0;
}
#include <stdio.h>

int main() {
int num, original, sum = 0, digit;

scanf("%d", &num);
original = num;

do {
digit = num % 10;
sum += digit * digit;
num /= 10;
} while (num != 0);

printf("%d", sum);

return 0;
}
#include <stdio.h>

int main() {
int a, b, sum = 0;
scanf("%d %d", &a, &b);
for (int i = a; i <= b; i++) {
if (i % 2 == 0) {
continue;
}
sum = sum + i;
}
printf("%d", sum);

return 0;
}
#include <stdio.h>

int main() {
long long int num, originalNum;
int i, lastDigit, fact, sum = 0;

scanf("%lld", &num);

originalNum = num;

while (num > 0) {


lastDigit = num % 10;
fact = 1;

for (i = 1; i <= lastDigit; i++) {


fact *= i;
}

sum += fact;

num /= 10;
}

if (originalNum == sum) {
printf("Strong number");
} else {
printf("Not a strong number");
}

return 0;
}

You might also like