Question

Write a function that takes an odd integer “q” from user and displays UFO shape using...

Write a function that takes an odd integer “q” from user and displays UFO shape using X’s and O’s

All UFO’s have 3 lines of X’s.

a is odd and a >=5.

EXAMPLE:

a = 9, displays

XXXXXXXXX

OXXXXXXXO

OOXXXXXOO

EXAMPLE:

a = 5, displays

XXXXX

OXXXO

OOXOO

IN C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:-

Screen shot of program:-

Sample output:-

Copy program:-

#include<iostream>

using namespace std;


int main()

{

int i,a;

cout<<"Enter a(a is odd and a>=5): ";

cin>>a;

if(a%2==1 && a>=5)

{

for(i=0;i<a;i++)

cout<<"X";

cout<<"\nO";

for(i=1;i<a-1;i++)

cout<<"X";

cout<<"O\nOO";

for(i=2;i<a-2;i++)

cout<<"X";

cout<<"OO\n";

}

else

{

cout<<"Error: a must be odd and greater than or equal to 5\n";

}

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Write a function that takes an odd integer “q” from user and displays UFO shape using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT