0% found this document useful (0 votes)
21 views

C Practical No 2

Practical

Uploaded by

kracompsci2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

C Practical No 2

Practical

Uploaded by

kracompsci2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Practical No:2

p1.Write c program to calculate area of circle

#include <stdio.h>
int main()
{
float radius,area,PI;
printf("Enter the radius of the circle: ");
scanf("%f", &radius);
area = 3.14 * radius * radius;
printf("The area of the circle is: %f", area);
return 0;
}

p2.Accept dimension of a cylinder and print the surface area and volume of
cyclinder

#include<stdio.h>
int main()
{
float r,h,area,volume;
printf("Enter Radius:");
scanf("%f",&r);
printf("Enter Height:");
scanf("%f",&h);
area = (2*3.14*r*r)+(2*3.14*r*r);
printf("Area of cyclinder is %f\n",area);
volume = 3.14*r*r*h;
printf("volume of cyclinder is %f",volume);
return 0;
}

p3.Accept the initial velocity(u),acceleration(a),time(t), print the float velocity


(v) and the distance (s) travelled (v=u+at,s=ut at^2)

#include<stdio.h>
int main()
{
float u,a,t,velocity,distance;
printf("Enter velocity:");
scanf("%f",&u);
printf("Enter Acceleration:");
scanf("%f",&a);
printf("Enter Time:");
scanf("%f",&t);
velocity=u+(a*t);
distance=u+(a*t*t);
printf("Velocity is:%f\n",velocity);
printf("Distance is:%f\n",distance);
return 0;
}

p4.Accept the three dimension length(L),breadth(b),height(h) of a cuboid and print


surface area of volume
Hint:Surface area:2((lb)+(lb)+(bh)),volume=lbh

#include<stdio.h>
int main()
{
float l,b,h,surfacearea,volume;
printf("Enter length:");
scanf("%f",&l);
printf("Enter breadth:");
scanf("%f",&b);
printf("Enter Height:");
scanf("%f",&h);
surfacearea=2*(l*b)+(l*b)+(b*h);
volume=l*b*h;
printf("Surface area is:%f\n",surfacearea);
printf("Volume is:%f\n",volume);
return 0;
}

p5.//Accept temperatures in Fahrenheit (F) and print it in Celsius(C) and Kelvin


(K) //Hint:C=5/8 (f -32),c=(5/9)*(f -32)
//k=c+273.15,k=c+273.15

#include<stdio.h>
int main()
{
float f,c,k,t;
printf("\nEnter temperature:");
scanf("%f",&t);
c=(0.55*f-32); // Formula C=5.0/9(F-32)
k=c+273.15;
printf("\nTemperature in celsius: %f\n",c);
printf("\nTemperature in kelvin: %f\n",k);
}

p6.//Accept two numbers in Arithmetic mean and harmonic mean


//AM=(a+b)/2 HM=ab/(a+b)

#include<stdio.h>
int main()
{
int a,b,AM,HM;
printf("Enter a:");
scanf("%d",&a);
printf("Enter b:");
scanf("%d",&b);
AM=(a+b)/2;
HM=(a*b)/(a+b);
printf("Arithmetic mean: %d\n",AM);
printf("Harmonic mean:%d\n",HM);
}

p7.//Accept outer and inner radius of a ring and print perimeter and area of ring
//area=3.14*((a*a)-(b*b)) peri=2*3.14*(a+b)

#include<stdio.h>
int main()
{
float a,b,peri,area;
printf("Enter outer radius:");
scanf("%f",&a);
printf("Enter inner radius:");
scanf("%f",&b);
area=3.14*((a*a)-(b*b));
peri=2*3.14*(a+b);
printf("Area: %f\n",area);
printf("Perimeter is:%f\n",peri);
}

p8.//Accept the character from user and print its ASCII value

#include<stdio.h>
void main()
{
char ch;
printf("Enter Character:");
scanf("%c",&ch);
printf("Character is:%c",ch);
printf("\n ASCII value is %d",ch);
}

p9.//Write a c program accept the input from user and print the addition.

#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter a:");
scanf("%d",&a);
printf("Enter b:");
scanf("%d",&b);
c=a+b;
printf("Addition is:%d",c);
}

p10.//Write a c program accept the input from user and print the multiplication.

#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter a:");
scanf("%d",&a);
printf("Enter b:");
scanf("%d",&b);
c=a*b;
printf("Multiplication is:%d",c);
}

You might also like