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

Assignment 1

Uploaded by

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

Assignment 1

Uploaded by

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

NAME-PRAJJWAL JOSHI

Roll Number-23BKT0072
QUESTIONS:
Q1)Write a C program to enter length in centimeter and convert it into meter and kilometer.
CODE:#include <stdio.h>

int main()
{
float cm=1000,meter,kilometer;
printf("Enter the length in centimeter:\n");
scanf("%f", &cm);
meter = cm/100.0;
kilometer = cm/100000.0;

printf("Length in Meter = %.2f m\n",meter);


printf("Length in Kilometer = %.2f lm\n",kilometer);

return 0;
}

Q2)Write a C program to enter temperature in Celsius and convert it into Fahrenheit


CODE:
#include <stdio.h>

float tempf;
float tempc;

int main()
{
printf("Input a temperature in Centigrade: ");
scanf("%f", &tempc);
tempf=((9.0/5.0)*tempc)+32.0;
printf("%f degrees Fahrenheit.\n", tempf);

return(0);
}

Q3)Write a C program to enter temperature in Fahrenheit and convert to Celsius


CODE:
#include <stdio.h>

float tempf;
float tempc;

int main()
{
printf("Input a temperature in Fahrenheit: ");
scanf("%f", &tempf);
tempc=(5.0*(tempf-32.0))/9.0;
printf("%f degrees Centigrade.\n", tempc);

return(0);
}

Q4)Write a C program to find power of any number x^y


CODE:
#include <stdio.h>
#include <math.h>

int main()
{
int x,y,c;
printf("Input the first number:");
scanf("%d", &x);
printf("Input the second number:");
scanf("%d", &y);
c=pow(x,y);
printf("The power of any number x^y: %d\n",c);

return(0);
}

Q5)Write a C program to enter any number and calculate its square root
CODE:
#include <stdio.h>
#include <math.h>

int main()
{
int x,root;
printf("Input the first number:");
scanf("%d", &x);
root=pow(x,0.5);
printf("The square root of any number: %d\n",root);

return(0);
}

Q6)Write a C program to enter two angles of triangle and find its third angle
CODE:
#include <stdio.h>

float main()
{
float a,b,c;
printf("Input the first angle of triangle:");
scanf("%f", &a);
printf("Input the second angle of triangle:");
scanf("%f", &b);
c=180.00-a-b;
printf("The Third angle of triangle: %.2f\n",c);

return(0);
}

Q7)Write a C program to enter base and height of a triangle and find its area.
CODE:
#include <stdio.h>

float main()
{
float base,height,area;
printf("Enter the base of triangle:");
scanf("%f", &base);
printf("Input the height of triangle:");
scanf("%f", &height);
area=0.50*base*height;
printf("The area of triangle: %f\n",area);

return(0);
}

Q8)Write a C program to calculate area of an equilateral triangle.


CODE:
#include <stdio.h>
#include <math.h>

float main()
{
float a,area;
printf("Enter the side of equilateral triangle:");
scanf("%f", &a);
area=(pow(3.0,0.5)/4.0)*a*a;
printf("The area of equilateral triangle: %f\n",area);

return(0);
}

Q9)Write a C program to enter marks of five subjects and calculate total, average and percentage.
CODE:
#include <stdio.h>

float main()
{
float a1,a2,a3,a4,a5,total,average,percent;
printf("Enter the marks of first subject:");
scanf("%f", &a1);
printf("Enter the marks of second subject:");
scanf("%f", &a2);
printf("Enter the marks of third subject:");
scanf("%f", &a3);
printf("Enter the marks of fourth subject:");
scanf("%f", &a4);
printf("Enter the marks of fifth subject:");
scanf("%f", &a5);
total=a1+a2+a3+a4+a5;
average=(a1+a2+a3+a4+a5)/5.0;
percent=(total/500.0)*100.0
printf("The area of triangle: %.2f\n",area);

return(0);
}

Q10)Write a C program to enter P, T, R and calculate Simple Interest.


CODE:
#include <stdio.h>

float main()
{
float p,r,t,SI;
printf("Enter the principle amount:");
scanf("%f", &p);
printf("Enter the time:");
scanf("%f", &t);
printf("Enter the rate of interest:");
scanf("%f", &r);
SI=(p*r*t)/100.00;
printf("The simple interest: %.2f\n",SI);

return(0);
}

Q11)Write a C program to enter P, T, R and calculate Compound Interest.


CODE:
#include <stdio.h>
#include <math.h>

float main()
{
float p,r,t,CI;
printf("Enter the principle amount:");
scanf("%f", &p);
printf("Enter the time:");
scanf("%f", &t);
printf("Enter the rate of interest:");
scanf("%f", &r);
CI=p*(pow((1+r/100.0),t));
printf("The compound interest: %.2f\n",CI);

return(0);
}

Q13)Write a C program to enter radius of a circle and find its diameter, circumference and area.
CODE:
#include <stdio.h>
pi=3.14;

float main()
{
float r,d,pt,area;
printf("Enter the radius of circle:");
scanf("%f", &r);
d=2*r;
pt=2.00*pi*r;
area=pi*r*r;
printf("The diameter of circle: %.2\n",d);
printf("The circumference of circle: %.2f\n",pt);
printf("The area of circle: %.2f\n",area);

return(0);
}

You might also like