Posts

6.If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item.

#include<stdio.h> int main() {      float s, p, c;      printf("Enter the selling price of 15 items: ");      scanf("%f", &s);      printf("Enter the profit on 15 items: ");      scanf("%f", &p);      c = (s-p)/15;      printf("\nThe cost price of an item is %f.", c);      return 0; }

5.Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D.

 #include<stdio.h> int main() {      int C, D, T;      printf("Enter the value of C: ");      scanf("%d", &C);      printf("Enter the value of D: ");      scanf("%d", &D);      C = C+D;      D = C-D;      C = C-D;      printf("\n The value of C: %d", C);      printf("\n The value of D: %d", D);      return 0; }

4.The length & breadth of a rectangle and radius of a Circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

 #include<stdio.h> int main() {      float l, b, r,ca, cc, ra, rp;      printf("Enter the length of rectangle: ");      scanf("%f", &l);      printf("Enter the breadth of rectangle: ");      scanf("%f", &b);      printf("Enter the radius of circle: ");      scanf("%f", &r);      ra = l * b;       rp = 2 * (l + b);       ca = 3.14 * r * r;       cc = 2 * 3.14 * r;       printf("\nThe area of the rectangle: %f", ra);      printf("\nThe perimeter of the rectangle: %f", rp);      printf("\n\nThe area of the circle: %f", ca);      printf("\nThe circumference of the circle: %f", cc);      return (0); }

3.Temperature of a city in Fahrenheit degrees is input through the keyboard.Write a program to convert this temperature into Centigrade degrees.

 #include<stdio.h> int main() {      float f, c;      printf("Enter Temperature in Fahrenheit: ");      scanf("%f", &f);      c= (f-32)*5/9;      printf("The Temperature in Centigrade Degree: %f", c);      return (0); }

2.The distance between two cities (in k.m.) is input at runtime.Write a program to convert and print this distance in meters,feet,inches,and centimeters.

 #include<stdio.h> int main() {      float km, m, cm, f, in;      printf("Enter distance in kilometers: ");      scanf("%f",&km);      m = 1000 * km;      printf("The distance in Meters: %f\n", m);      cm = 1000 * 100 * km;      printf("The distance in Centimeters: %f\n", cm);      f    = 3280.84 * km;      printf("The distance in Feet: %f\n", f);      in = 39370.08 * km;      printf("The distance in Inches: %f\n", in);      return (0); }

1.The basic salary is input through the keyboard. His dearness allowance is 40% of basic salary,and house rent allowance is 20% of basic salary.Write a program to calculate his gross salary.

#include<stdio.h> int main() {           float bs,da,hra,gs;           printf("Enter Your Basic Salary---");           scanf("%f",&bs);           da=(40 * bs)/100;           printf("\nYour DA is:-%f",da);           hra=(20 * bs)/100;           printf("\nYour HRA is:-%f",hra);           gs=bs+da+hra;           printf("\nYour Total Salary is:-%f",gs);           return 0; }