4. program that inputs the names and monthly salaries of 10 employees. If annual salary is greater than or equal to Rs 2,50000/- then it prints name, salary and a message "Tax to be paid" else it prints name, salary and a message "No tax".
Chapter 7:
Arrays
Programming Exercise
Problem # 4:
Write a program that inputs the names and monthly salaries of 10 employees. The program checks annual salary of each person. If annual salary is greater than or equal to Rs 2,50000/- then it prints name, salary and a message "Tax to be paid" else it prints name, salary and a message "No tax".
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
char name[10][15];
int i, sal[10], A_sal[10];
for(i=0;i<10;i++)
{
cout<<"\nEnter name:";
cin>>name[i];
cout<<"Enter salary:";
cin>>sal[i];
A_sal[i]=sal[i]*12;
if(A_sal[i]>=250000)
{
cout<<"\nName="<<name[i]<<endl;
cout<<"Salary="<<sal[i]<<endl;
cout<<"Tax to be paid."<<endl;
}
else
{
cout<<"\nName="<<name[i]<<endl;
cout<<"Salary="<<sal[i]<<endl;
cout<<"No tax."<<endl;
}
}
}
#include<conio.h>
using namespace std;
int main ()
{
char name[10][15];
int i, sal[10], A_sal[10];
for(i=0;i<10;i++)
{
cout<<"\nEnter name:";
cin>>name[i];
cout<<"Enter salary:";
cin>>sal[i];
A_sal[i]=sal[i]*12;
if(A_sal[i]>=250000)
{
cout<<"\nName="<<name[i]<<endl;
cout<<"Salary="<<sal[i]<<endl;
cout<<"Tax to be paid."<<endl;
}
else
{
cout<<"\nName="<<name[i]<<endl;
cout<<"Salary="<<sal[i]<<endl;
cout<<"No tax."<<endl;
}
}
}
Output:
Let me know in the comment section if you have any question.
Previous Post:
3. Program that consists of four arrays representing numbers, thier squares, their cubes and sums array stores the corresponding sums of three arrays each consisting of 10 elements.
Comments
Post a Comment