EX NO:01 NAME:
DATE: REG NO:
EVALUATION OF EXPRESSION
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,x,y,z,w;
clrscr();
printf("Enter value for x:");
scanf("%d",&x);
printf("Enter value for y:");
scanf("%d",&y);
printf("Enter value for z:");
scanf("%d",&z);
printf("Enter value for w:");
scanf("%d",&w);
a=(x*x)+(y+y)+(2*x*y);
b=x+z;
c=a*b; d=c/w;
printf("The value is: %d",d);
getch();
}
Output:
Enter value for x:2
Enter value for y:4
Enter value for z:5
Enter value for w:2
The value is:126
EX NO:02 NAME:
DATE: REG NO:
TEMPERATURE CONVERSION PROBLEM
#include<stdio.h>
#include<conio.h>
void main()
{
float f,c;
clrscr();
printf("Enter Temperature in Fahrenheit : ");
scanf("%f",&f);
c=(f-32)*5/9;
printf("Temperature in Celsius : %f",c);
getch();
}
Output:
Enter Temperature in Fahrenheit :100
Temperature in Celsius:37.778
EX NO:03 NAME:
DATE: REG NO:
PROGRAM TO CONVERT DAYS TO MONTHS AND
DAYS
#include<stdio.h>
#include<conio.h>
void main()
{
int d,m,rd;
printf("Enter The Number of Days:");
scanf("%d",&d);
m=d/30;
rd=d%30;
printf("Months=%d",m);
printf("Remaining Days=%d",rd);
getch();
}
Output:
Enter The Number of Days:365
Months:12
Remaining Days:5
EX NO: 04 NAME:
DATE: REG NO:
SOLUTION OF QUADRATIC EQUATION
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d,e,f,g;
clrscr();
printf("Enter a value");
scanf("%d",&a);
printf("Enter b value");
scanf("%d",&b);
printf("Enter c value");
scanf("%d",c);
d=(b*b)-(4*a*c);
f=-b+e;
g=f/2;
printf("The result is :%d",g);
getch();
}
Output:
Enter a value:2
Enter b value:2
Enter c value:2
The result is :1
EX NO: 05 NAME:
DATE: REG NO:
CALCULATION OF SALESMAN SALARY
#include<stdio.h>
#include<conio.h>
void main()
{
int basic_salary,bonus_per_item,total_sales,total_salary;
clrscr();
printf("Basic Salary:");
scanf("%d",&basic_salary);
printf("Bonus Per Item:");
scanf("%d",&bonus per_item);
printf("Commission:");
scanf("%d",&commission);
printf("Total Sales:");
scanf("%d",&total_sales);
total_salary=basic_salary+(bonus_per_item*total_sales)+(commission*total_sales);
printf("Total Salary : %d",total_salary);
getch();
}
Output:
Basic Salary:5000
Bonus Per Item:10
Commission:10
Total Sales:100
Total Salary:7000
EX NO: 06 NAME:
DATE: REG NO:
MAXIMUM OF THREE NUMBERS
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,;
clrscr();
printf("Enter the first number :");
scanf("%d",&a);
printf("Enter the second number :");
scanf("%d",&b);
printf("Enter the third number:");
scanf("%d",&c);
if(a>b && a>c){
printf(" %d is the largest number",a);}
else if(b>a && b>c){
printf(" %d is the largest number",b);}
else{
printf(" %d is the largest number",c);}
getch();
}
Output:
Enter the first number:25
Enter the second number:45
Enter the third number:80
80 is the largest number
EX NO: 07 NAME:
DATE: REG NO:
SQUARE ROOT OF FIVE NUMBERS
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double a,b,i;
clrscr();
for(i=1;i<=5;i++)
{
printf("Enter the number:”);
scanf("%lf",&a);
if(a<0)
{
printf("Cannot calculate the square root of a negative number");
}
else
{
b=sqrt(a);
printf("Square root of %lf is %5.2lf\n",a,b);
}
}
getch();
}
Output:
Enter the number:4
Square root of 4.000000 is 2.00
Enter the number:64
Square root of 64.000000 is 8.00
Enter the number:9
Square root of 9.000000 is 3.00
Enter the number:121
Square root of 121.000000 is 11.00
EX NO:08 NAME:
DATE: REG NO:
PAY BILL CALCULATION FOR DIFFERENT LEVELS
OF EMPLOYEE
#include<stdio.h>
#include<conio.h>
#define CA1 1000
#define CA2 750
#define CA3 500
#define CA4 250
#define EA1 500
#define EA2 200
#define EA3 100
#define EA4 0
void main()
{
int level,jobnumber;
float gross,basic,house_rent,perks,net,tax;
clrscr();
printf("Enter your level:");
scanf("%d",&level);
printf("Enter your job number:");
scanf("%d",&jobnumber);
printf("Enter your basic pay:");
scanf("%f",&basic);
if(level==1)
{
perks=CA1+EA1;
printf("Perks=%f\n",perks);
}
else if(level==2)
{
perks=CA2+EA2;
printf("Perks=%f\n",perks);
}
else if(level==3)
{
perks=CA3+EA3;
printf("Perks=%f\n",perks);
}
else if(level==4)
{
perks=CA4+EA4;
printf("Perks=%f\n",perks);
}
else
{
printf("Invalid level");
}
house_rent=basic*0.25;
printf("House rent is %f\n",house_rent);
gross=basic+house_rent+perks;
printf("Gross salary is %f\n",gross);
if(gross<=2000)
{
tax=0;
printf("Tax is %f",tax);
}
else if(gross<=4000)
{
tax=0.03*gross;
printf("Tax is %f",tax);
}
else if(gross<=5000)
{
tax=0.05*gross;
printf("Tax is %f",tax);
}
else
{
tax=0.08*gross;
printf("Tax is %f\n",tax);
}
net=gross-tax;
printf("Net salary of the employee is %f",net);
getch();
}
Output:
nter your level:1
Enter your job number:1234
Enter your basic pay:5000
Perks=1500.000000
House rent is 1250.000000
Gross salary is 7750.000000
Tax is 620.000000
Net salary of the employee is 7130.000000
EX NO:09 NAME:
DATE: REG NO:
FIBONACCI SERIES
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,a=0,b=1,c;
clrscr();
printf("Enter the number of terms:"\n);
scanf("%d",&n);
printf("Fibonacci series:");
for(i=1;i<=n;i++)
{
printf("%d",a);
c=a+b;
a=b;
b=c;
}
getch();
}
Output:
Enter the number of terms:7
Fibonacci series:0112358
EX NO:10 NAME:
DATE: REG NO:
FLOYDS TRIANGLE
#include<stdio.h>
#include<conio.h>
void main()
{
int a,n=1,i,j;
printf("Enter the number of rows:");
scanf("%d",&a);
for(i=1;i<=a;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",n);
n++;
}
printf(“\n”);
}
getch();
}
Output:
Enter the number of rows:5
1
23
456
78910
1112131415