67 069
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #30198 in C++ for Tayyab Raza

Question #30198
Input the gender of 10 students and display how many students are male or female??
Expert's answer
#include <iostream>
using namespace std;

const int STUDENTS_COUNT = 3;
const char* MALE = "male";
const char* FEMALE = "female";

int main()
{
char buffer[20] = {};//buffer for user input
int maleCount = 0 ,
femaleCount = 0;

for(int i=0;i<STUDENTS_COUNT;i++)
{
cout<<"Input gender(male ro female) of student # "<<i+1<<" : ";
cin>>buffer;
if(!stricmp(buffer,MALE))
maleCount++;
else if(!stricmp(buffer,FEMALE))
femaleCount++;
}

cout<<"\nMale students : "<<maleCount<<endl;
cout<<"Female students : "<<femaleCount<<endl;

system("pause");

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions