You are on page 1of 12

• COMPUTER PRACTICALS•

NAME :ALTAMASH MEMON


CLASS : SYBCOM
SUBJECT : COMPUTER PRACTICALS
ROLL NO : 34

[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

Q2 Write a program to input 2 integers and display the


difference between them.
#include <stdio.h>
#include<conio.h>
Main()
{
Int x,y;
Float d;
Printf(“enter the number”);
Scanf(“%d%d”,&x,&y);
D=x-y;
Printf(“the difference of integer=%f”,d);
Getch();
Return(0);
}
Output:
Enter the number 3 5
The difference of integer=2.000000

Q3 Write a program to display your details in the following


format
First Name :
Surname :
Age :
Address:
City :

#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);

Puts(“your first name is”);


Puts(f);
Puts(“your surname is”);
Puts(s);
Printf(“your age is %d”,a);
Puts(“your address is”);
Puts(ad);
Puts(“your city is”);
Puts©;
Printf(“your pin is %d”,p);
Getch();
Return(0);
}
Output:
Enter the first name ALTAMASH
Enter the surname MEMON
Enter the age 19
Enter the address TALOJA PHASE 2,GOLDEN
TOWER,KHARGHAR.
Enter the city MUMBAI
Enter the pin 410208
Your first name is ALTAMASH Your surname is
MEMON
Your age is 19
Your address is TALOJA PHASE 2, GOLDEN TOWER,
KHARGHAR.
Your city is MUMBAI
Your pin is 410208

Q4 Write a program to find the input the base and height of a


triangle and calculate its area (a = ½ * b * h)

#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

Q5 Write a program to input the side of a square and calculate


its perimeter p = s*4
#include<stdio.h>
#include<conio.h>
Main()
{
Float s,p;
Printf(“enter the side”);
Scanf(“%f”,&s);
P=s*4;
Printf(“the perimeter of square=%f”,p);
Getch();
Return(0);
}
Output:
Enter the side 8
The perimeter of square =32.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

Q2 Write a program to input 2 integers and display its sum,


difference, product and division.

#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

Q3 Write a program to input the name and salary of an


employee and display its da, hra, pf, gross and net where da=
5% of salary, hra = 2% of salary,pf = 3% of salary, gross = sal +
da + hra, net = gross – pf

#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

Q4 Input a measurement in meters and convert it into cms (1


meter = 100 cms)

#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

Q5 Write a program to input a number and display whether it’s


even or odd.

#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]

Q1 Write a program to input the salary of an employee and then


calculate the income tax at 10%.
(Note : First 5,000 Rs is tax free)

#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

Q2 . Write a program to input 2 integers and a sign ( + , - , * , / )


and display and display the result as per the sign.
#include<stdio.h>
#include<conio.h>
Main()
{
Int x,y,tol;
Char a;
Printf(“enter the number”);
Scanf(“%d%d%c”,&x,&y,&a);
{
Case +;
Total=x+y;
Printf(“\n additional=%d”,tol);
Break;
}
Case=-;
Tol=x-y;
Printf(“\n substraction=%d”,tol);
Case*;
Tol=x*y
Printf(“\n multiplation=%d”,tol);
Break;
Case \
Tol=x/y;
Printf(“\ndivision=%d”,tol);
Break;
}
Getch();
Return(0);
}

Q3 Write a program to input the name and marks of a student in


3 subjects and then calculate his total and average. Also display
his grade as per the following conditions Average Grade >=75 A
>=60 B

#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

Q4 . Write a program to input the name and marks of a student


in 3 subjects and then calculate his total and average. Also
display his result as pass or fail. A student is considered as pass
if he scores above 40 in each subject else he has failed.

#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

Q3 Write a program to input 2 positive integers and display the


sum of all integers between those 2 integers.

#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

Q4 Write a program to display the sum of 1+10+100+1000.

#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

You might also like