#Include : Int Char
#Include : Int Char
Ans:- #include<stdio.h>
void main()
float fahrenheit,convert;
scanf("%f",&fahrenheit);
2. Write a c program Accept a character from the user and display its ASCII
value.
3. Write a C program accept dimensions of a cylinder and print the surface area
and volume.
Ans:- #include<stdio.h>
void main()
{
float r,h,v,A; //declare variables r=radius, h=height , v=volume , A=area
float p=3.14;
//accepting radius(r) and height(h)
printf("\nEnter Value of radius:");
scanf("%f",&r);
printf("\nEnter Value of height:");
scanf("%f",&h);
A=(2*p*r*h)+(2*p*r*r); //formula of surface area of cylinder
v=p*r*r*h; //formula of volume of cylinder
printf("Surface Area of Cylinder :- %f ",A);
printf("Volume of Cylinder :- %f ",v);
}
4. Write a c program accept initial velocity (u), acceleration (a) and time (t).
Print the final velocity (v) andthe distance.
Ans:- #include<stdio.h>
void main()
{
int sec;
float distance , initial_velocity,velocity, acceleration;
printf("Enter the time in seconds \n");
scanf("%d",&sec);
printf("Enter the initial velocity \n");
scanf("%f", &initial_velocity);
printf("Enter the acceleration \n");
scanf("%f", &acceleration);
velocity = (initial_velocity + (acceleration * sec));
distance = (initial_velocity + (acceleration * (sec*sec)));\
printf("Total velocity is %f",velocity);
printf("Total distance travelled is %f", distance);
int main()
{
/* Declaring variables */
float length, breadth, area, perimeter;
/* Displaying result */
printf("Area of rectangle = %f", area);
printf("\nPerimeter of rectangle = %f", perimeter);
return 0;
}
6. write a c program to Accept inner and outer radius of a ring and print the
perimeter.
Ans:- #include <stdio.h>
int main()
{
float out_radius,in_radius,area, perimeter;
printf("Enter inner radius of ring:\n ");
scanf("%f",&in_radius);
printf("Enter outer radius of ring:\n ");
scanf("%f",&out_radius);
perimeter= (2 * 3.14) * (in_radius + out_radius);
area= 3.14 * ((in_radius * in_radius) + (out_radius * out_radius));
printf("Area of circle: %f \nPerimeter of circle: %f\n",area,perimeter);
}
7. Write a c program accept two numbers and print arithmetic and harmonic
mean of the two numbers
Sol:- #include<stdio.h>
void main()
{
int a,b;
float AM, HM; // AM=Arithmetic Mean , HM=Harmonic Mean
//Accept 2 numbers
printf("Enter the 1st number: ");
scanf("%d",&a);
printf("Enter the 2nd number: ");
scanf("%d",&b);