C programming: if else statement to find cost of a carpool
activity:
You are planning a car trip so you post on a carpooling website in order to share the cost of the trip.
If you have 0 passengers the carpool site does not charge anything and you alone pay the full cost of the trip. If you have 1 or more passengers the carpool site adds a $1 fee to the cost of the trip and evenly divides the total cost ($1 fee + gas) among the passengers and you. You want to write a program that calculates the cost you have to pay. The program should read the number of passengers (an integer) and the cost of gas for the trip (a decimal number). The program should then print the cost that you have to pay (a decimal number) with 2 digits after the decimal point.
Examples:
Input
0 23.9
Output
23.90
Input
2 45.5
Output
15.50
Видео C programming: if else statement to find cost of a carpool канала I am learning
You are planning a car trip so you post on a carpooling website in order to share the cost of the trip.
If you have 0 passengers the carpool site does not charge anything and you alone pay the full cost of the trip. If you have 1 or more passengers the carpool site adds a $1 fee to the cost of the trip and evenly divides the total cost ($1 fee + gas) among the passengers and you. You want to write a program that calculates the cost you have to pay. The program should read the number of passengers (an integer) and the cost of gas for the trip (a decimal number). The program should then print the cost that you have to pay (a decimal number) with 2 digits after the decimal point.
Examples:
Input
0 23.9
Output
23.90
Input
2 45.5
Output
15.50
Видео C programming: if else statement to find cost of a carpool канала I am learning
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
C Programming: Add Two Complex Numbers by Passing Structure to a FunctionC programming :Factorial of number with recursionC program : how to display Fibonacci sequencec programming : how to count lines from input ??C programming :simple program with MallocC programming : 1- storing / 2- display/ 3- number of words / 4 - reverse / 0- exit+100 C programming videos and thanks 44 subscribershow to calculate the circumference of a circle in c programhow to show ASCII code in c programC programming : Find the Number of Lines in a Text FileC programming : if else statement : hostel costhow to change lowercase to uppercase in c program ;C program: To count alphabets,numbers and spaces .C Programming: Calculate Average Using Arrayshow to make a simple multiplication in c program.C programming : is a multiple of 3 or a multiple of 7 ??C programming : create a simple linked listC program :how many hour,minute,secondC programming: Find the maximum number between two numbers : pointerC programming : Demonstrate the use of & and * operators