codescracker


c++

C++ Program to Print Smiling Face on Screen



« Previous Program Next Program »


Print Smiling Face on Screen in C++

To print smiling face on the screen in C++ programming, first you have to ask from the user that how many smiling face he/she want to print on the output screen to print required number of smiling face on the screen. So to print smiling face on the screen, use the ASCII value of smiling face, which is 1, first make a variable say sml of int type and initialize 1 to it. Now make a variable say ch of type char and initialize sml to ch. After performing this, ch is now contains smiling face, now print the required number of smiling face on the screen as shown here in the following program..

C++ Programming Code to Print Smiling Face on Screen

Following C++ program ask to the user that how many smiling face he or she want to print on the screen to print the required number of smiling face on the screen:

/* C++ Program - Print Smiling Face on Screen */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int sml=1, i, limit;
	char ch=sml;
	cout<<"How many smiley face you want to print ? ";
	cin>>limit;
	for(i=0; i<limit; i++)
	{
		cout<<ch<<" ";
	}
	getch();
}

When the above C++ program is compile and executed, it will produce the following result:

C++ program print smiling face

You can also format the output screen of the smiling face as per your requirement

Same Program in Other Language

You may like the same program in other programming language:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test