Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

/* programm to check whether the input year is leap year or not

Name-Pranjal Dalakoti

Roll No-46

Section-J1

Course-Btech

Branch-CSE

*/

#include <stdio.h>

int main()

int yr; //initializing variable

printf("Enter the year - ");

scanf("%d",&yr); // taking input

if((yr%100)==0) //using conditional statement to check if given year is a leap year

if((yr%400)==0)

printf(" this is a leap year ");

else

printf(" this is not a leap year ");

}
}

else

if((yr%4)==0)

printf(" this is a leap year ");

else

printf(" this is not a leap year ");

Output:

Enter the year – 2022

this is not a leap year


/* programm to check whether the input is alphabet , number or symbol

Name-Pranjal Dalakoti

Roll No-46

Section-J1

Course-Btech

Branch-CSE

*/

#include <stdio.h>

int main()

char ch;

printf("Enter any character: ");

scanf("%c", &ch);

if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))

printf("'%c' is alphabet.", ch);

else if(ch >= '0' && ch <= '9')

printf("'%c' is digit.", ch);

else

printf("'%c' is special character.", ch);

return 0;

Output :

Enter any character: a

‘a’ is alphabet
/* program to find the average of marks of two out of three subjects which are greater

Name-Pranjal Dalakoti

Roll No-46

Section-J1

Course-Btech

Branch-CSE

*/

#include <stdio.h>

int main()

int a,b,c;

float avg; //initializing variable

printf("enter marks of maths ");

scanf("%d",&a); // taking input

printf("enter marks of physics ");

scanf("%d",&b);

printf("enter marks of chemistry ");

scanf("%d",&c);

if(a<b&&a<c) //using conditional statement to check the greater marks

{
avg=((b+c)/2.0);

else if(b<a&&b<c)

avg=((a+c)/2.0);

else if(c<b&&c<a)

avg=((a+b)/2.0);

else

avg=((a+b)/2.0);

printf("average of the two greater marks is %f ",avg);

Output:

enter marks of maths 68

enter marks of physics 70

enter marks of chemistry 72

average of the two greater marks is 71

You might also like