Answer to Question #198881 in C for Ali khan

Question #198881

Write a program that declares a structure to store income tax, tax rate and tax of 

a person. The program defines an array of structure to store the record of five 

persons. It inputs the income and tax rate of five persons and then displays the 

tax payable.


1
Expert's answer
2021-05-26T10:38:16-0400
#include <stdio.h>
#include <stdlib.h> 


struct Person{
	float income;
	float taxRate;
	float taxPayable;
};


int main() {
	// defines an array of structure to store the record of five persons.
	struct Person persons[5];
	int i;
	for(i=0;i<5;i++){
		printf("Enter the person's income: ");
		scanf("%f",&persons[i].income);
		printf("Enter the person's tax rate: ");
		scanf("%f",&persons[i].taxRate);
		persons[i].taxPayable=persons[i].income*(persons[i].taxRate/100.0);
		printf("\n");
	}


	for(i=0;i<5;i++){
		printf("The person %d has tax payable %.2f.\n",(i+1),persons[i].taxPayable);
	}


	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