You are on page 1of 7

PRACTICAL SET-2

2.1.Write a c program to find that the accepted number is


Negative,Positive or Zero.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

{int n;

clrscr();

printf("Enter number n:");

scanf("%d",&n);

if(n>=0)

{if(n>0)

{printf("number is positive");}

else

{printf("number is zero");}}

else

{printf("number is negative");}

getch();}
2.2.Write a program to read marks of a student from keyboard whether
the student is pass or fail.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

int m;

clrscr();

printf("Enter student's marks:");

scanf("%d",&m);

{if

(m>=23)

printf("Student is pass");

else

printf("Student is fail");

getch();

}
2.3.Write a program to read three numbers from keyboard & find out
maximum out of these three.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

int A,B,C;

clrscr();

printf("Enter three numbers A,B,C");

scanf("%d %d %d",&A,&B,&C);

if(A>B && A>C)

{printf("A is maximum");}

else

{if(B>A && B>C)

{printf("B is maximum");

else

{printf("C is maximun");}

getch();

}
2.4 Write a C program to check whether the entered digit is Capital letter,
Small letter, any special character or symbol.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

{char ch;

clrscr();

printf("Enter any character:");

scanf("%c",&ch);

if(ch>=65&&ch<=90)

{ printf(" character is Capital letter");}

else if (ch>=97&&ch<=122)

{ printf(" Character is small letter");}

else if (ch>=48&&ch<=57)

{ printf("Character is a digit");}

else if((ch>=0&&ch<=47)||(ch>=58&&ch<=64)||(ch>=91&&ch<=96)||(ch>=123&&ch<=126))

{ printf("Character is symbol");}

else

{ printf("Enter valid character");}

getch();}
2.5.Write a program to read marks from keyboard & your program should
display equivalent grade.(80 to 100=distinction,60 to 79=first class,40 to
59=second class,<40=fail)
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

float m;

clrscr();

printf("Enter marks:");

scanf("%f",&m);

if(m>=80 && m<=100)

{printf("Grade is disinction");}

else if(m>=60 && m<=79)

{printf("Grade is first class");}

else if(m>=40 && m<=59)

{printf("Grade is second class");}

else{printf("Student is fail");}

getch();

}
2.6.Write ac program to prepare pay slip using.(Da=10% of
basic,Hra=7.50% of basic,Ma=300,Pf=12.50% of
basic,Gross=basic+Da+Hra+Ma,Nt=Gross-Pf).
PROGRAM:

include<stdio.h>

#include<conio.h>

void main()

{float basic,du,hra,nu,pf,nt,gross;

clrscr();

printf("\nEnter basic salery:");

scanf("%f",&basic);

du=basic*0.10;

hra=basic*0.07050;

pf=basic*0.1250;

nu=300;

gross=basic+du+hra+nu;

nt=gross=pf;

printf("\n Duty allowness is=%f",du);

printf("\n House rent is allowness is=%f",hra);

printf("\n Net salary is=%f",nt);

getch();}
2.7.Write a C program to read no 1 to 7 & print relativity day Sunday to
Saturday.
PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

{int ch;

clrscr();

printf("Please enter the number of the day:");

scanf("%d",&ch);

{case1:printf("Monday");

break;

case2:printf("Tuesday");

break;

case3:printf("Wednesday");

break;

case4:printf("Thuursday");

break;

case5:printf("Friday");

break;

case6:printf("Saturday");

break;

case7:printf("Sunday");

break;

default:printf("Enter the void number between 1 to 7"); break;}

getch();}

You might also like