coding in c for hiring a car,a travel agency charges r1 rupees per hour for first n hour and then r2 per hour.given the total time of travel in minute is x.the task is to find the total travelling cost in rupees coding in python
Answers
Answer: C program is given below
Concept : Basic Programming
Given : For hiring a car, a travel agency charges r1 rupees per hour for
first n hour and then r2 per hour. Given the total time of travel in
minute is x.
To Find : The task is to find the total travelling cost in rupees.
Explanation:
// C program to calculate the total travelling cost
#include<stdio.h> // pre - processor directives
#include<conio.h>
int main(){ // main function
int r1, r2, n, x, hr_to_min ; // variable declaration
float total_cost;
printf("Enter the charge r1 for first n hours :");
scanf("%d%d", &r1, &n); // Taking input from user
printf("Enter the amount r2");
scanf("%d", &r2);
printf("Total time of travel in minutes :");
scanf("%d", &x);
hr_to_min = 60 * n; // Converting hour to minute
total_cost = (r1 * n) + (r2 * ((x - 60 * n)/60));
// Formula to calculate total cost in rupees
printf("Total travelling cost in rupees is : %f", total_cost);
// Printing the final value
getch();
}
#SPJ3