1- Write a program to accept a number from the user then check the given number is even or odd?.
#include <stdio.h>
#include<conio.h>
void main()
{
int n,r;
clrscr();
printf(“\n Enter a number”);
scan(“%d”, &n);
r=n%2;
if (r==0)
{
printf(“\n %d” is even”, n);
}
else
printf(“\n %d” is odd”, n);
getch();
}
2-Wap to accept two numbers from the user then print the greater number?
#include <stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“\n Enter first number”);
scan(“%d”, &a);
printf(“\n Enter second number”);
scan(“%d”, &b);
if(a>b)
{
printf(“\n %d” is greatest”, a);
}
else
printf(“\n %d” is greatest”, b);
getch();
}
3- Wap to accept two numbers from the user then print the smaller number?
#include <stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf(“\n Enter first number”);
scan(“%d”, &a);
printf(“\n Enter second number”);
scan(“%d”, &b);
if(a<b)
{
printf(“\n %d” is smallest”, a);
}
else
printf(“\n %d” is smallest”, b);
getch();
}
4- Wap to accept a roll number, three subject marks of a students and calculate total, average marks. If average marks is greater then 30 then print pass other wise print fail with roll no.l total, average marks of students.
#include <stdio.h>
#include<conio.h>
void main()
{
int roll, m1,m2,m3;
float total, avg;
clrscr();
printf(“\n Enter Roll number”);
scan(“%d”, &roll);
printf(“\n Enter mark m1”);
scan(“%d”, &m1);
printf(“\n Enter mark m2”);
scan(“%d”, &m2);
printf(“\n Enter mark m3”);
scan(“%d”, &m3);
total=m1+m2+m3;
avg=total/3;
printf(“\n roll number is %d”, roll);
printf(“\n total marks is %f”, total);
printf(“\n avarge marks is %f”, avg);
if(avg>30)
{
printf(“\n “pass”);
}
else
printf(“\n “fail”);
getch();
}
5-Wap to accept three number from user then print the greater number.
#include <stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(“\n Enter first number”);
scan(“%d”, &a);
printf(“\n Enter second number”);
scan(“%d”, &b);
printf(“\n Enter third number”);
scan(“%d”, &c);
if(a>b)
{
if(a>c)
{
printf(“\n %d” is greatest”, a);
}
}
else
{
if(b>c)
{
printf(“\n %d” is greatest”, b);
}
else
{
printf(“\n %d” is greatest”, c);
}
}
getch();
}
if(bs>8000)
7- Wap to accept roll no and three subject marks of student then print roll no total marks, avg marks and grade of student if avg marks greater than equal to 75 then grade in A. if avg marks in greater than equal to 60 then print ‘B, if avg marks in greater than and equal to 45 and c 60 then print grade ‘c’ if avg marks is greater than equal to 30 then print grade D otherwise print grade E. printf(“\n Enter mark m3”);
}
6- Wap to accept code at basic salary tof employee if b is gretaer then 8000/- then calculate ta=40%, da=30%,of bs & HRA =1000 otherwise calculate ta=10% of bs, da=40% DA and HRA =500 then print employee code basic salary and gross salary of employee.
#include <stdio.h>
#include<conio.h>
void main()
{
int code, bs, ta, da, hra, gp;
clrscr();
printf(“\n Enter code”);
scan(“%d”, &code);
printf(“\n Enter employee bs”);
scan(“%d”, &bs);
{
ta=bs* 4;
da= bs* 3;
hra=1000
}
else
{
ta=bs* 1;
da= bs* 4;
Hra=500
}
gp=bs+ta+da+hra;
printf(“code employee is %a”, code);
printf(“basic salary employee is %d”, bs);
printf(“gross pay %d”, gp);
getch();
}
#include <stdio.h>
#include<conio.h>
void main()
{
int roll, m1,m2,m3;
float total, avg;
clrscr();
printf(“\n Enter Roll number”);
scan(“%d”, &roll);
printf(“\n Enter mark m1”);
scan(“%d”, &m1);
printf(“\n Enter mark m2”);
scan(“%d”, &m2);
scan(“%d”, &m3);
total=m1+m2+m3;
avg=total/30;
printf(“\n roll number is %d”, roll);
printf(“\n total marks is %f”, total);
printf(“\n avarge marks is %f”, avg);
if(avg>=75)
{
printf(“grade ‘A’);
}
else
if(avg>=60)
{
printf(“grade ‘B’);
}
else
if(avg>=45)
{
printf(“grade ‘C’);
}
else
if(avg>=30)
{
printf(“grade ‘D’);
}
else
{
printf(“grade ‘E’);
}
getch();
}
No comments:
Post a Comment