PES1UG24CS579 Week3
PES1UG24CS579 Week3
#include<stdio.h>
int main(){
int a;
printf("Enter your score: ");
scanf("%d",&a);
if (a <= 100 && a>= 90) {
printf("A \n");}
else if (a>= 80) {
printf("B \n");}
else if (a >= 70){
printf("C \n");}
else if (a>= 60) {
printf("D\n");}
else {
printf("F \n");}
return 0;}
QUESTION 2:
#include<stdio.h>
int main(){
int mon;
printf("Enter the month number: ");
scanf("%d" , &mon);
if (mon == 1 || mon == 3 || mon == 5 || mon ==7 || mon == 8|| mon ==10 || mon ==
12) {
printf("This month has 31 days \n");}
else if (mon == 2){
printf("This month has 28 days \n");}
else if (mon == 4||mon == 6|| mon ==9 || mon ==11){
printf("This month has 31 days \n");}
else{
printf("Invalid choice \n");}
0 return;
}
QUESTION 3:
#include<stdio.h>
int main(){
int a;
printf("Enter the number: ");
scanf("%d" , &a);
if (a%2==0) printf("The number is even \n");
else printf("The number is odd \n");
return 0;
}
QUESTION 4:
#include<stdio.h>
int main(){
int a;
printf("Enter the number: ");
scanf("%d" , &a);
if (a<0) printf("The given number is negative \n");
else printf("The given number is positive \n");
return 0;
}
QUESTION 5:
#include<stdio.h>
int main(){
char c;
printf("Enter the character: ");
scanf("%c",&c);
if (c == "a" || c == "e" || c == "i" || c == "o" || c == "u" || c == "A" || c ==
"E" || c == "I" || c == "O" || c == "U") printf("The given character is a vowel \n"
);
else printf("The given character is a consonant \n");
return 0;
}
QUESTION 6:
int main(){
int a,b,c,d,e;
printf("Enter your marks in the following order {Physics Chemistry Maths Biology
Computer}: ");
scanf("%d%d%d%d%d" , &a,&b,&c,&d,&e);
float p;
p = (a+b+c+d+e)/5.0;
printf("Your percentage is %f \n" , p);
if (p >= 90) printf("Your grade is A \n");
else if (p >= 80) printf("Your grade is B \n");
else if (p >= 70) printf("Your grade is C \n");
else if (p >= 60) printf("Your grade is D \n");
else if (p >= 40) printf("Your grade is E \n");
else printf("Your grade is F\n");
return 0;
}
QUESTION 7:
#include<stdio.h>
int main(){
int a;
printf("Enter any year: ");
scanf("%d" , &a);
if (a%4 == 0 && a%100!= 0) printf("The given year is a leap year \n");
else if (a%400 == 0) printf("The given year is a leap year \n");
else printf("The given year is not a leap year \n");
return 0;
}