Skip to main content

Posts

Distance between two cities

Q. The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimetres. Sol 1 : #include <stdio.h> int main() {     int  m, cm;     float km, f, i;     printf("Distance between two cities (in km) = ");     scanf_s("%f", &km);     getchar();     m = 1000 * km;     cm = 100 * m;     i = cm / 2.54;     f = i / 12;     printf("This distance in \nmeter = %d \t centimeter=%d \t inch = %f \t feet = %f   ", m, cm, i, f);     getchar();     return 0; } Output : Distance between two cities (in km) = 25 This distance in meter = 25000    centimeter=2500000      inch = 984251.937500    feet = 82020.992188 Sol 2 : Hint: ...
Recent posts

Gross Salary

Q.   Ramesh's 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() {     int salary;     float  da, hra, tsalary;     printf("Hi Ramesh just give me your name Basic salary =\t");     scanf_s("%d", &salary);     getchar();     da = 0.4*salary;     hra = 0.2*salary;     tsalary = da + hra + salary;     printf("\nHey Ramesh, You told your basic salary is =%d \n So,\n Dearness Allowance = %f\t House rent allowance = %f\t Total Salary = %f",salary,da,hra,tsalary);     getchar();     return 0; } Output : Hi Ramesh just give me your name Basic salary = 1000 Hey Ramesh, You told your basic salary is =1000  So,  Dearness Allowance =...