Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Print a Semicolon Without Using a Semicolon

    C Programming Examples


    Generally when use printf() statement we have to use semicolon at the end.

    If we want to print a semicolon, we use the statement: printf(";");

    In above statement, we are using two semicolons. The task of printing a semicolon without using semicolon anywhere in the code can be accomplished by using the ascii value of  ; which is equal to 59.

    Program:

    #include <stdio.h>
    
    int main(void) {
        //prints the character with ascii value 59, i.e., semicolon
        if (printf("%c ", 59)) {
          //prints semicolon
        }
        return 0;
    }
    

    Program Output:

    ;

    Explanation:

    If statement checks whether return value of printf function is greater than zero or not. The return value of function call printf("%c",59) is 1. As printf returns the length of the string printed. printf("%c",59) prints ascii value that corresponds to 59, that is semicolon ;.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.