1. Write C Program to Print hello.
Input
#include<stdio.h>
#include<conio.h>
int main()
{
Clrscr();
print("HELLO FY BSC CS");
getch();
}
OUTPUT
2. Write C Program to add, subtract, and multiply ad divide two numbers.
1. Program:Write a code for Addition(sum)
#include<stdio.h>
#include<conio.h>
int main()
{
int n1,n2,sum;
n1=200;
n2=500;
sum=n1+n2;
printf("\nsum=%d",sum);
getch();
}
Output:
sum = 700
2. Program:Write a code for Subtraction
Page 1
, PSP LAB
#include<stdio.h>
#include<conio.h>
int main()
{
int n1,n2,Sub;
n1=200;
n2=500;
Sub=n1-n2;
printf("\nSub=%d",Sub);
getch();
return 0;
}
Output:
Sub= -300
3. Program:Write a code for Multiplication
#include<stdio.h>
#include<conio.h>
int main()
{
int n1,n2,Mul;
n1=200;
n2=500;
Mul=n1*n2;
printf("\nMul=%d",Mul);
getch();
return 0;
}
Output:
Mul= -31072
4. Program:Write a code for Division
#include<stdio.h>
#include<conio.h>
Page 2
, PSP LAB
int main()
{
int n1,n2,Div;
n1=200;
n2=600;
Div=n1/n2;
printf("\nDiv=%d",Div);
getch();
}
Output:
Div= 0;
3. Write steps for Writing and Running C program.
Steps :-
1.C PROGRAM RUN’s IN TURBOC3
2.Click TurboC++ Icon on Desktop
3.It will open C EDITOR
4.Click alt+F
5.Click NEW
6.Start Typing the Program in Editor
SAVING C PROGRAM
Click alt+F
With Arrow Keys go to Option Save
Save Window Will Open
Save The Program Name
C:\TURBOC3\BIN\addition.C
And Press Enter
Your Prgram Will Be Saved
Compiling AND Running C Program
Press alt+c & Enter [ to compile the program ]
If any Error Exists try to remove the error and save the Program
For Running the Program Click alt+R & ENTER
Page 3
, PSP LAB
Output will be there on the Screen
4. Write a c Program to create calculator by accepting two numbers and perform addition
subtraction, multiplication, division and modulus operation.
Program:Write a code to create Calculator
#include<stdio.h>
#include<conio.h>
int main()
{
int n1,n2,Sum,Sub,Mul,Div;
printf("\nEnter two numbers:");
scanf("\n%d",&n1);
scanf("\n%d",&n2);
printf("\nSum=%d", n1+n2);
printf("\nSub=%d", n1-n2);
printf("\nMul=%d", n1*n2);
printf("\nDiv=%d", n1/n2);
getch();
return 0;
}
Output:
Enter two numbers: 50
20
Sum=70
Sub=30
Mul=1000
Div=2
Page 4