In this tutorial you will learn about the C Program to Print Smiling face and its application with practical example.
C Program to Print Smiling face
In this tutorial, we will learn to create a C program that will Print Smiling face in C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- For loop in C programming.
Program to Print Smiling face
As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First, we will take the input number from the user for a number of smiles. Then we will Print the Smiling face using the for loop. The ASCII value of 1 is smile.
With the help of this program, we can Print a Smiling face
Algorithm:-
1 2 3 4 5 6 7 8 9 |
1. Declare the variables for the program. 2. Take the input string from the user. 3. <strong>Swap Two Strings</strong>. 4. Print the output. 5. End the program. |
Program to Print Smiling face:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/* C Program to Print Smiling face */ #include<stdio.h> void main() { //Declaing the variable for the program int smile=1, i, limit; //smile= It will hold the integer value 1 which is smile in ASCII //i = It will hold the integer value for controlling the for loop //limit = It will hold the integer value for the number of smily //Taking the input from the user for quantity of smile. printf("How many smiley face you want to print ? "); scanf("%d",&limit); //Printing the smile with the help of for loop for(i=0; i<limit; i++) { printf("%c ",sml); } return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- smile= It will hold the integer value 1 which is a smile in ASCII.
- i = It will hold the integer value for controlling the for loop.
- limit = It will hold the integer value for the number of smiles.
Taking the input number of smiles.