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

Where the memory to the static variables is allocated?

0 Answers  


What are all predefined data types in c++?

0 Answers  


Are strings immutable in c++?

0 Answers  


If we declare two macro with the same identifier without doing undef the first, what will be the result? eg: #define MAX_SIZE 100 #define MAX_SIZE 200 int table1[MAX_SIZE];

3 Answers  


Why do we use pointers in c++?

0 Answers  






What are the uses of c++ in the real world?

0 Answers  


write a function signature with various number of parameters.

0 Answers  


Is c++ pass by reference or value?

0 Answers  


How can a called function determine the number of arguments that have been passed to it?

0 Answers  


Explain this pointer?

0 Answers  


Can we make copy constructor private in c++?

0 Answers  


What is virtual constructor paradigm?

5 Answers   HCL, HP,


Categories