Aim: 2.1 Write a program to convert the Celcius to Farenheit. {F=( C*1.8 )+32}
Code:
#include <stdio.h>
int main()
{
float c,f;
printf("Enter Temperature in Celcius : ");
scanf("%f",&c);
f=(c*1.8)+32;
printf("\nTemperature in Fahrenheit : %f",f);
}
Output screenshot:
Aim: 2.2 Write a program to calculate simple interest (i = (p*r*n)/100 )
i = Simple interest
p = Principal amount
r = Rate of interest
n = Number of years
Code:
#include <stdio.h>
int main()
{
int n;
float p, r, i
printf("Enter Principle amount p : ");
scanf("%f",&p);
printf("\nEnter Rate of interest r : ")
scanf("%f",&r);
printf("\nEnter Number of Years n : ");
scanf("%d",&n);
i = (p*r*n)/100;
printf("\nSimple Interest = %f",i);
return 0;
}
Output screenshot:
Aim: 2.3 Write a program to find area of triangle(a=h*b*.5)
a = area
h = height
b = base
Code:
#include <stdio.h>
int main()
{
float base, hight, area;
printf("Enter base of the triangle : ");
scanf("%f", &base);
printf("Enter hight of the triangle : ");
scanf("%f", &hight);
area=(base*hight)/2;
printf("Area of the triangle = %.2f", area);
return 0;
}
Output screenshot:
Aim: 2.4 Write a C program to find out distance travelled by the equation d = ut + at^2
Code:
#include <stdio.h>
int main()
{
float u,a,d;
int t;
printf("Enter the value of a : ");
scanf("%f",&a);
printf("\nEnter the value of u : ");
scanf("%f",&u);
printf("\nEnter the value of t : ");
scanf("%d",&t);
d = (u*t)+(a*t*t)/2;
printf("\nThe Distance : %.2f",d);
return 0;
}
Output screenshot:
Aim: 2.5 Write a c program to prepare pay slip using following data.
Da = 10% of basic, Hra = 7.50% of basic, Ma = 300,
Pf = 12.50% of basic, Gross = basic + Da + Hra + Ma, Nt = Gross – Pf.
Code:
#include<stdio.h>
int main()
{
float basic;
printf("Enter Basic Salary : ");
scanf("%f",&basic);
printf("\nSALARY SLIP");
printf("\n");
printf("\nBasic : %.2f",basic);
printf("\nDA : %.2f",basic*0.10);
printf("\nHRA : %.2f",basic*0.075);
printf("\nMA : %.2f",300.00);
printf("\nPF : %.2f",basic*0.125);
printf("\nGROSS : %.2f",basic+(basic*0.10)+(basic*0.075)+300.00);
printf("\nNET : %.2f",(basic+(basic*0.10)+(basic*0.075)+300.00)-(basic*0.125));
return 0;
}
Output screenshot:
No comments:
Post a Comment
If you have any doubts or suggestions, Please let me know