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.


Expert's answer

#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;
}




LATEST TUTORIALS
APPROVED BY CLIENTS