Professional Documents
Culture Documents
[Practical 1]
Q1 Write a program to input an integer and display it on the
screen.
#include<stdio.h>
#include<conio.h>
Main()
{
Int x;
Printf(“enter the number”);
Scanf(“%d”,&x);
Printf(“the number entered is an integer +%d”,x);
Getch();
Return(0);
Text
}
Output:
Enter the number 8
The number is an integer8
#include<stdio.h.>
#include<conio.h>
Main()
Char f[15],s[15],ad[100],c[20];
Int a,p;
Puts(“enter the first name”);
Gets(f);
Puts(“enter the surname”);
Gets(s);
Printf(“enter the age”);
Scanf(“%d”,&a);
Puts(“enter the address”);
Gets(ad);
Puts(“enter the city”);
Gets©;
Printf(“enter the pin”);
Scanf(“%d”,&p);
#include<stdio.h>
#include<conio.h>
Main()
{
Float b,h,a;
Printf(“enter the base and height”);
Scanf(“%f%f”,&b,&h);
A=0.5*b*h;
Printf(“the area of triangle=%f”,a);
Getch();
Return(0);
}
Output:
Enter the base and height 5 4
The area of triangle=10.000000
[PRACTICAL 2]
Q1 Write a program to input an integer and display its half.
#include <stdio.h>
#include<conio.h>
Main()
{
Int x;
Float h;
Printf(“Enter the integer”);
Scanf(“%d”,&x);
H=x/2;
Printf(“The half of an integer=%f”,h);
Getch();
Return(0);
}
Output:
Enter the number 50
The half of an integer=25.000000
#include<stdio.h>
#include<conio.h>
Main()
{
Int a,b;
Float sum,diff,pro,div;
Printf(“enter the integers”);
Scanf(“%d%d”,&a,&b);
Sum=a+b;
Diff=a-b;
Pro=a*b;
Div=a/b;
Printf(“the sum of numbers=%f”,sum);
Printf(“the diff of numbers=%f”,diff);
Printf(“the product of numbers=%f”,pro);
Printf(“the division of numbers=%f”,div);
Getch();
Return(0);
}
Output:
Enter the integers 54 38
The sum of numbers=92.000000
The diff of numbers=16.000000
The product of numbers=2052.000000
The division of numbers=1.000000
#include<stdio.h>
#include<conio.h>
Main()
{
Char n[15];
Int sal;
Float da,hra,pf,gross,net;
Printf(“enter the name and salary”);
Scanf(“%s%d”,&n,&sal);
Da=sal*0.05;
Hra=sal*0.02;
Pf=sal*0.03;
Gross=sal+da+hra;
Net=gross-pf;
Printf(“the name and salary of employee=%s%d”,n,sal);
Printf(“\n da of salary=%f”,da);
Printf(“\n hra of saalry=%f”,hra);
Printf(“\n pf of salary=%f”,pf);
Printf(“\n gross of salary=%f”,gross);
Printf(“\n net of salary=%f”,net);
Getch();
Return(0);
}
Enter the name and salary Altamash 8000
The name and salary of employee=Altamash8000
Da of salary=400.000000
Hra of saalry=160.000000
Pf of salary=240.000000
Gross of salary=8560.000000
Net of salary=8320.000000
#include<stdio.h>
#include<conio.h>
Main()
{
Float m,cm;
Printf(“enter the meters”);
Scanf(“%f”,&m);
Cm=m*100;
Printf(“convert into centimeters=%f”,cm);
Getch();
Return(0);
}
Output:
Enter the meter 38
Convert into centimeters=3800.000000
#include <stdio.h>
#include<conio.h>
Main()
{
Int x;
Printf(“enter the number”);
Scanf(“%d”,&x);
If(x%2==0)
{
Printf(“\nEven”);
}
Else
{
Printf(“\nOdd”);
}
Printf(“the number is an integer=%d”,x);
Getch();
Return(0);
}
Output:
Enter the number 7
Odd
The number is an integer=7
[PRACTICAL 3]
#include<stdio.h>
#include<conio.h>
Main()
{
Int sal,tax;
Printf(“enter the salary”);
Scanf(“%d”,&sal);
If(tax>5000)
{
Tax=sal*0.1;
}
Else
{
Tax=0;
}
Printf(“the tax on salary =%d”,tax);
Getch();
Return(0);
}
Enter the salary 9000
The tax on salary =900
#include<stdio.h>
#include<conio.h>
Main()
{
Char n[15];
Float m1,m2,m3,t,avg;
Scanf(“%f%of”,&m1,&m2,&m3);
T=m1+m2+m3;
Avg=t/3;
If(avg>=75)
{
Printf(“grade A\n”);
}
If(avg>=60)
{
Printf(“grade B\n”);
}
Else
{
Printf(“grade C\n”);
}
Printf(“the total of marks=%f”,t);
Printf(“the average of marks=%f”,avg);
Getch();
Return(0);
}
Output
60 70 80
Grade c
The total of marks= 60.000000
The average of marks=20.000000
#include<stdio.h>
#include<conio.h>
Main()
{
Char n[15];
Float m1,m2,m3,t,avg;
Printf(“enter the name”);
Scanf(“%s”,&n);
Printf(“enter the marks of three subjects”);
Scanf(“%f%f%f”,&m1,&m2,&m3);
T=m1+m2+m3;
Avg=t/3;
If(m1>40,m2>40,m3>40)
{
Printf(“\n pass”);
}
Else
{
Printf(“\n fail”);
}
Printf(“the total of marks=%f”,t);
Printf(“the average of marks=%f”,avg);
Getch();
Return(0);
}
OUTPUT:
Enter the namealtamash
Enter the marks of three subjects 70 80 90
Pass
The total of marks=240.000000
The average of marks=80.000000
[PRACTICAL 4]
Q1 Write a program to display the sum of even numbers greater
than 5 and less then 15.
#include<stdio.h>
#include<conio.h>
Main()
{
Int I;
Float s=0;
For(i=6;i>15;i=i+2);
{
S=s+I;
}
Printf(“the sum of number=%f”,s);
Getch();
Return(0);
}
Output:
The sum number=6.000000
Q2 Write a program to display the numbers 15 to 20 in
descending order.
#include<stdio.h>
#include<conio.h>
Main()
{
Int I;
For(i=20;i>=15;i--)
{
Printf(“%8d\n”,i);
}
Getch();
Return (0);
}
OUTPUT: 20
19
18
17
16
15
#include<stdio.h>
#include<conio.h>
Main()
{
Int I,x,y;
Float s=0;
Printf(“enter two integers”);
Scanf(“%d%d”,&x,&y);
For(i=x;i<y;i++)
{
S=s+I;
}
Printf(“the sum of series=%f”,s);
Getch ();
Return(0);
}
OUTPUT:
Enter the two integers 10 25
The sum of series=255.000000
#include<stdio.h>
#include<conio.h>
Main()
{
Int I;
Float s=0;
For(i=1;i<=1000;i=i*10)
{
S=s+I;
}
Printf(“the sum of series=%f”,s);
Getch();
Return(0);
}
Output:
The sum of series=0.000000the sum of series=1111.000000