Hi all,

I am new to C++ and I am having trouble with the syntax. I am suppose to write code for this question:

//Write a program in which the funtion main prompts the user for one of the six letters a, b, p, q, x, or y. The function main then invokes one of the six functions print_a, print_b, print_q, print_x, or print_y. Each prints a large uppercase version of the letter made out of the corresponding lowercase letter. (None has any arguments.) For example, if the user enters letter p, print_p prints something like:
//
// ppppppppp
// ppp ppp
// ppp ppp
// ppp ppp
// ppppppppp
// ppp
// ppp
// ppp
// ppp

I am having trouble calling the functions. Any help is appreciated. Thanks.

#include <iostream>
using namespace std;

void print_a ()
{
cout << "aaaaaaaaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaaaaaaaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaa   aaa" << endl;
cout << "aaa   aaa" << endl;
}
void print_b ()
{
cout << "bbbbbbbbb" << endl;
cout << "bbb   bbb" << endl;
cout << "bbb   bbb" << endl;
cout << "bbb   bbb" << endl;
cout << "bbbbbbbbb" << endl;
cout << "bbb   ppp"<< endl;
cout << "bbb   bbb" << endl;
cout << "bbb   bbb" << endl;
cout << "bbbbbbbbb" << endl;
}
void print_p ()
{
cout << "ppppppppp" << endl;
cout << "ppp   ppp" << endl;
cout << "ppp   ppp" << endl;
cout << "ppp   ppp" << endl;
cout << "ppppppppp" << endl;
cout << "ppp" << endl;
cout << "ppp" << endl;
cout << "ppp" << endl;
cout << "ppp" << endl;
}
void print_q ()
{
cout << "qqqqqqqqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqq" << endl;
cout << "qqq   qqqqqq" << endl;
cout << "qqqqqqqqq" << endl;
}
void print_x ()
{
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
cout << " xxxxxxx " << endl;
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
cout << "xxx   xxx" << endl;
}
void print_y ()
{
cout << "yyy   yyy" << endl;
cout << "yyy   yyy" << endl;
cout << "yyy   yyy" << endl;
cout << "yyy   yyy" << endl;
cout << "yyyyyyyyy" << endl;
cout << "      yyy" << endl;
cout << "      yyy" << endl;
cout << "      yyy" << endl;
cout << "yyyyyyyyy" << endl;
}
void main()
{
	char letter;
	cout << "Enter one of these six letter - a,b,p,q,x,y: " << endl;
	cin >> letter;

	if (letter = 'a')
	{
		print_a();
	}
	else if (letter = 'b')
	{
		print_b();
	}
	else if (letter = 'p')
	{
		print_p();
	}
	else if (letter = 'q')
	{
		print_q();
	}
	else if (letter = 'x')
	{
		print_x();
	}
	else if (letter = 'y')
	{
		print_y();
	}
	
	system("pause");
}

Recommended Answers

All 3 Replies

line 82: use == operator, not = assignment operator. Same on other if statements.

Thank you it works great :)

void main()

void main is incorrect, the two official entry-point headers are: int main() and int main(int argc, char *argv[])

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.