Answer to Question #217493 in C for Anandharaman

Question #217493
A worker takes a job for 5 days. His pay for the day 1 is Rs. X, for day 2 is Rs. 2X and so on. Develop a C program to find the total salary.
1
Expert's answer
2021-07-15T07:32:13-0400
#include <stdio.h>
int main(){
	float salary;
	float totalSalary=0;
	int day=0;
	//get the salary of one day
	printf("Enter the salary of one day: ");
	scanf("%f",&salary);
	//find the total salary.
	for(day=1;day<=5;day++){
		totalSalary+=day*salary;
	}
	printf("\nThe total salary for 5 days is: %.2f\n\n",totalSalary);


	getchar();
	getchar();
	return 0;
}





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS