Friday, December 4, 2020

Write a C program that accepts principle, rate of interest, time and compute the simple interest.

 /*Write a C program that 

accepts principle, rate of 

interest, time and compute 

the simple interest. 

Test Data:

Input Data: p = 10000, 

r = 10% , t = 12 year

Expected Output:

Input principle, Rate of 

interest & time to find 

simple interest:

Simple interest = 12000

*/

#include <stdio.h>

int main()

{

  int p,r,t,interest;

  printf("p = ");

  scanf("%d",&p);

  printf("r = ");

  scanf("%d",&r);

  printf("t = ");

  scanf("%d",&t);

  interest=((r*p*t)/100);

  printf("Simple interest:\

  %d\n",interest);

  return 0;

}

Write a C program that accepts a distance in centimeters and prints the corresponding value in inches.

 /*Write a C program that 

accepts a distance in 

centimeters and 

prints the corresponding 

value in inches. 

Test Data:

Input Data: 500cms

Input the distance in cm:

Distance of 500.00 cms is = 

196.85 inches

*/

#include <stdio.h>

#define cms 2.54

int main()

{

  float cm,result;

  printf("Input the distance\

 in cm: ");

  scanf("%f",&cm);

  result=(cm/cms);

  printf("Distance of %.2f \

  \ncms is = %.2f inches",cm,

  result);

  return 0;

}