Badboy is defined who has ALL the following properties:

1. Does not have a girlfriend and is not married.
2. He is not more than 23 years old.
3. The middle name should be "Singh"
4. The last name should have more than 4 characters.
5. The character 'a' should appear in the last name at
least two times.
6. The name of one of his brothers should be "Ram"

Write a method:

boolean isBadBoy(boolean hasGirlFriend , boolean isMarried,
int age , String middleName , String lastName , String[]
brotherName);

isHaveGirlFriend is true if the person has a girlfriend
isMarried is true if the person is married
age is the age of the person
middleName is the middle name of the person
lastName is the last name of the person
brotherName is the array of the names of his brothers



Badboy is defined who has ALL the following properties: 1. Does not have a girlfriend and is n..

Answer / pramod kumar srivastava

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char gf[25],f_name[10],m_name[10],l_name[25],brother_name[20];
int age;
char a[10],b[10];
cout<<"enter the f_name";
cin>>f_name;
cout<<"enter your middle name";
cin>>m_name;
cout<<"enter your last name";
cin>>l_name;
cout<<"enter your age";
cin>>age;
cout<<"are you have girlfriend yes / no";
cin>>a;
if(a=="yes")
{
cout<<"enter gf name";
cin>>gf;
cout<<" is have gf";
}
if(a=="no")
{
cout<<"no gf";
}
cout<<"r u married";
cin>>b;
if(b=="yes")
{
cout<<"he is married";
}
if(b=="no")
{
cout<<"single";
}




cout<<"enter your brother name\n";
cin>>brother_name;
cout<<"age is: "<<age;
cout<<"\nmiddlename is"<<m_name;
cout<<"\nlast name is: "<<l_name;
cout<<"\nbrother name is: "<<brother_name;
if((age<=23)&&(m_name=="singh")&&(brother_name=="ram")&&(a=="no")&&(b=="no"))
{
cout<<"he is bad boy";
}

getch();
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ General Interview Questions

please help to write the code of chess game in c++??????????

1 Answers   NEC,


Where and why do I have to put the "template" and "typename" keywords?

0 Answers  


Explain the scope of resolution operator.

0 Answers  


Can you overload the operator+ for short integers?

0 Answers  


What is the difference between method overloading and method overriding in c++?

0 Answers  






Difference between an inspector and a mutator

0 Answers  


How can virtual functions in c++ be implemented?

0 Answers  


Why do we need pointers?

0 Answers  


What is ios class in c++?

0 Answers  


what is Loop function? What are different types of Loops?

0 Answers  


Is c++ still in demand?

0 Answers  


What is a 'pure' virtual function and what's its use?

1 Answers  


Categories