/* Write a C-Program to check given number is even or not */
#include<stdio.h>
#include<conio.h>
main()
{
int n;
printf("Enter number\n");
scanf("%d", &n);
if (n%2 == 0)
printf("%d is a even number\n",n);
else
printf("%d is a odd number\n",n);
getch();
}
Output:
Enter number
4
4 is a even number
/* Write a C-program to find biggest number from given three numbers */
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("%d is a biggest number",a);
}
else
{
printf("%d is a biggest number",c);
}
}
else
{
if(b>c)
{
printf("%d is a biggest number",b);
}
else
{
printf("%d is a biggest number",c);
}
}
getch();
}
Output:
enter three numbers4
6
5
6 is a biggest number
/* Write a C-program to check given year is a leap year or not */
#include<stdio.h>
#include<conio.h>
main()
{
int year;
printf("Enter year\n");
scanf("%d", &year);
if (year%4 == 0)
printf("%d is a leap year\n",year);
else
printf("%d is a leap year\n",year);
getch();
}
Output:
Enter year
2020
2020 is a leap year
/*Write a C-program to find total, average, grade for given six subjects marks*/
#include <stdio.h>
#include<conio.h>
main()
{
int s1,s2,s3,s4,s5,s6,tot,avg;
char gr;
float per;
printf("enter six subjects marks");
scanf("%d%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5,&s6);
tot=s1+s2+s3+s4+s5+s6;
avg=tot/6;
per=(tot/600.0)*100;
if(avg>=90)
gr='A';
else if(avg>=80&&avg<90)
gr='B';
else if(avg>=70&&avg<80)
gr='C';
else if(avg>=60&&avg<70)
gr='D';
else
gr='E';
printf("total marks is:%d\n",tot);
printf("average marks is:%d\n",avg);
printf("percentage is:%.2f\n",per);
printf("grade is:%c\n",gr);
getch();
}
Output:
enter six subjects marks85
96
87
63
85
98
total marks is:514
average marks is:85
percentage is:85.67
grade is:B
/* Write a C-program to arithmetic operations using switch statement */
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
int ch;
printf("Enter the values of a & b: ");
scanf("%d%d",&a,&b);
printf(" 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n5.Modular\n");
printf("Enter your Choice :");
scanf("%d",&ch);
switch(ch)
{
case 1: c=a+b;
printf("Addition Value is : %d",c);
break;
case 2: c=a-b;
printf("Subtraction value is : %d",c);
break;
case 3: c=a*b;
printf("Multiplication value is : %d",c);
break;
case 4: c=a/b;
printf("Division value is : %d",c);
break;
case 5: c=a%b;
printf("Modular Division value is : %d",c);
break;
default :
printf(" Enter Your Correct Choice.");
break;
}
getch();
}
Output:
Enter the values of a & b: 4
6
1.Addition
2.Subtraction
3.Multiplication
4.Division
5.Modular
Enter your Choice :3
Multiplication value is : 24