/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
/* OF LOOPS, PARENTHESES AND CONDITIONS!
/* A conversation with computer to display artistic features on screen. */
#include <stdio.h>
/* Hey computer! Remember the things that you already are familiar with? */
main()
/* Let me get straight to the point here! */
{
/* 1) Can you start by defining two variables which are integers? Name them i and j! */
int i, j;
/* I would like you to first ask me to enter a number of my choice! */
printf ("Enter a number of your choice:");
/* you will know when i entered the number */
scanf ("%d", &i);
/* please check which number i entered. If my number is less than 55, note that */
if (i < 55)
/* So, like we decided earlier, if number is less than 55, let us do the following */
{
/* change the value of i to 1 and check if the original number i entered was less than/equal to 111 */
for (i = 1; i<=111; i++)
/* if yes, do the following */
{
/* make the second integer j equal to 1. Also, please make sure j stays less than/equal to the value of 1 */
for (j = 1; j <= i; j++)
/* ok! cool! if j is less than/equal to i, print "*" on the screen */
{
/* print only as many times as the value of j. So, 1 time on the first try, two time on second etc!! */
printf("*",j);
}
/* after printing line of *s each time, go to a new line so that it looks artistic */
printf("\n");
}
/* Alright! So we know what to do if i enter a number less than 55! */
return 0;
/* But, what about if the number is greater than 55?! Confused face?! */
}
/* Well! Let us try this for a number entered greater than 55 */
else
{
/* just like before, please check if the number i entered is less than or equal to 111 */
while
(i <= 111)
{
/* if that is true, make the second integer equal to 1 */
j = 1;
/* Now, as long as j is less than or equal to the number i entered, all is good */
while (j <= i)
{
/* we will do two new things here: */
printf("&");
/* 1) if the previous conditions satisfy, please print & for me on the screen! */
/* 2) print & as many times as the number i entered and then increase till you reach 111 */
/* for example, if i entered 8, print & eight times is a line, then nine times in a line, up to 111 */
j++;
}
printf("\n");
i++;
}
}
/* we did it!!! Thank you computer! You can relax now! */
return 0;
}