0

I'm trying to display rotating "HELLO!" in my program, but instead i get a just flashing "HELLO!" rather than rotating "HELLO!" which is mean to display 'H'1st, then 'E', then 'L' and so on in new line. Hope some master here can point out my mistake.

#include <iostream>
#include <cstdlib>
using namespace std;

void displayH()
{
	cout<<"H   H"<<endl;
	cout<<"H   H"<<endl;
	cout<<"HHHHH"<<endl;
	cout<<"H   H"<<endl;
	cout<<"H   H"<<endl;
	cout<<endl;
}

void displayE()
{
	cout<<"EEEEE"<<endl;
	cout<<"E"<<endl;
	cout<<"EEE"<<endl;
	cout<<"E"<<endl;
	cout<<"EEEEE"<<endl;
	cout<<endl;
}

void displayL()
{
	cout<<"L"<<endl;
	cout<<"L"<<endl;
	cout<<"L"<<endl;
	cout<<"L"<<endl;
	cout<<"LLLLL"<<endl;
	cout<<endl;
}

void displayO()
{
	cout<<" OOO "<<endl;
	cout<<"O   O"<<endl;
	cout<<"O   O"<<endl;
	cout<<"O   O"<<endl;
	cout<<" OOO "<<endl;
	cout<<endl;
}

void displayEx()
{
	cout<<"!"<<endl;
	cout<<"!"<<endl;
	cout<<"!"<<endl;
	cout<<"!"<<endl;
	cout<<"!"<<endl;
	cout<<endl;
}

void callFunction(char call1, char call2, char call3, char call4, char call5, char call6)
{	
	bool loop = true;
	char temp = call1;
	call1 = call2;
	call2 = call3;
	call3 = call4;
	call4 = call5;
	call5 = call6;
	call6 = temp;
	while(loop)
	{	
		switch(call1)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
			switch(call2)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
			
			switch(call3)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
		
			switch(call4)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
		
			switch(call5)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
		
			switch(call6)
			{
				case 'h': displayH();
				break;
				case 'e': displayE();
				break;
				case 'l': displayL();
				break;
				case 'o': displayO();
				break;
				case '!': displayEx();
				break;
			}
		for(int i = 0; i < 100000; i++)
		{
		
		}system("cls");
	}
}
int main()
{	
	char call1, call2, call3, call4, call5, call6; 
	cout<<"Enter a character.\n";
	cin>>call1>>call2>>call3>>call4>>call5>>call6;
	callFunction(call1, call2, call3, call4,call5,call6);
	
	return 0;
}
2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by WaltP
0
int main()
{	
	char call1, call2, call3, call4, call5, call6; 
	cout<<"Enter a character.\n";
	cin>>call1>>call2>>call3>>call4>>call5>>call6;
	callFunction(call1, call2, call3, call4,call5,call6);
	
	return 0;
}

Your main() makes no sense.
You output a prompt asking for a character.
Then you input 6 characters. Why? What if I enter "smiley"?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.