OUTPUT:
ENTER RADIUS > 1#include <stdio.h>
ENTER HEIGTH > 5000
VOLUME = 6.28 CUBIC METERS
#define PI 3.14159
int mani()
{
double r, r, h;
printf (" Enter Radius >");
scanf ("%lf", &r );
printf (" Enter Heigth >");
scanf ("%lf", &h );
v = PI*r*r*h
printf (" Volume=%.2fcubic",v);
return 0;
}
Laboratory 2
Write a function that will compute the volume of a Cylinder use a function in a main program to compute the volume of a cylinder whose outer radius is r1, inner radius r2 and a heigth of h.
OUTPUT:
ENTER OUTER RADIUS > 10
ENTER INNER RADIUS > 5
VOLUME = XX.XX CUBIC UNITS
#include <stdio.h>
#define P1 3.14159
double compVolume(double r, double h )
{
double v;
v = P1*r*r*h;
return v;
}
int main()
{
double vr1, vr2, vc, r1,r2, h;
printf ("Enter Outer Radius > ");
scanf ("%lf",&r1);
printf ("Enter Inner Radius > ");
scanf ("%lf",&r2);
printf ("Enter height > ");
scanf ("%lf",&h);
vr1 = compVolume(r1,h);
vr2 = compVolume(r2,h);
vc = vr1-vr2;
printf ("volume=%.2f cubic units",vc);
return 0;
}
#include <stdio.h>
#define P1 3.14159
double compVolume(double r, double h )
{
double v;
v = P1*r*r*h;
return v;
}
int main()
{
double vr1, vr2, vc, r1,r2, h;
printf ("Enter Outer Radius > ");
scanf ("%lf",&r1);
printf ("Enter Inner Radius > ");
scanf ("%lf",&r2);
printf ("Enter height > ");
scanf ("%lf",&h);
vr1 = compVolume(r1,h);
vr2 = compVolume(r2,h);
vc = vr1-vr2;
printf ("volume=%.2f cubic units",vc);
return 0;
}
Laboratory 3
#include <stdio.h>
int main()
{
char fni,mni,lni,bos;
double up,nos,tc,dcnt;
printf("Enter your Initials >");
scanf("%c%c%c", &fni,&mni,&lni,);
printf("What shampo will you buy? \n A) Palm\n B) Live\n");
printf("Enter your choice (A/B) >");
scanf(" %c",&bos);
printf("How many will you buy! >");
scanf ("%lf",&nos);
if (bos='A')
{
up=5.0;
if (nos>=12)
dcnt=0.05;
else
dcnt=0;
}
else
{
up=7.0;
if (nos>=12)
dcnt=0.10;
else
dcnt=0;
}
tc=up*nos* (1-dcnt);
printf("%c%c%c, that will cost %.2fpesos",fni,mni,lni,tc);
return 0;
}
Laboratory 4
#include <stdio.h>
double detDcnt(int n, char bor)
{
double d;
switch (bor)
{
case'a':
case'A':
if(n<10)
d=0;
else if(n<50)
d=0.07;
else
d=0.12;
break;
case'b':
case'B':
if(n<10)
d=0;
else if(n<50)
d=0.09;
else
d=0.15;
break;
case'c':
case'C':
if(n<10)
d=0;
else if(n<50)
d=0.05;
else
d=0.10;
}
return d;
}
int main()
{
char fni,mni,lni,bor;
double up,nos,tc,dcnt;
printf("Enter your Initials >");
scanf("%c%c%c", &fni,&mni,&lni);
printf("What shampo will you buy? \n \tA) grow\n \tB) sweet\n \tB) cheap\n");
printf("Enter your choice (A,B,C) >");
scanf(" %c",&bor);
printf("\nHow many will you buy? >");
scanf ("%lf",&nos);
switch (bor)
{
case'a':
case'A': up=900.0;
dcnt=detDcnt(nos,bor);
break;
case'b':
case'B': up=950.0;
dcnt=detDcnt(nos,bor);
break;
case'c':
case'C': up=800.0;
dcnt=detDcnt(nos,bor);
break;
}
tc=up*nos* (1-dcnt);
printf("%c%c%c, that will cost %.2fpesos",fni,mni,lni,tc);
return 0;
}
clangaugeivy.blogspot.com
No comments:
Post a Comment