Easy Tutorial
❮ C Macro Va_End C Exercise Example100 ❯

C Exercise Example 10

C Language Classic 100 Examples

Title: Print a staircase, along with two smiley faces above it.

Program Analysis: Use ASCII 1 to output smiley faces; use i to control rows and j to control columns, with j varying based on i to control the number of black squares output.

If you encounter garbled characters, please refer to the solution in C Exercise Example 7.

Example

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include<stdio.h>

int main()
{
    int i,j;
    printf("\1\1\n"); /* Output two smiley faces */
    for(i=1;i&lt;11;i++)
    {
        for(j=1;j<=i;j++)
            printf("%c%c",219,219);
        printf("\n");
    }
    return 0;
}

The above example outputs:

C Language Classic 100 Examples

❮ C Macro Va_End C Exercise Example100 ❯