Skip to main content

Sample C Program to Print any Print Statement without using Semicolon




# include <stdio.h>

void main()
{

    if(printf("Hi.. Welcome to sanfoundry"))
    {
    }

}


OUTPUT:

Hi.. Welcome to sanfoundry



Sample C Program To Display Its Own Source Code As Its Output.

# include <stdio.h>

int main()
{

    FILE *fp;
    char ch;
    fp = fopen(__FILE__,"r");

    do
    {
        ch = getc(fp);
        putchar(ch);
     }

     while (ch != EOF);
     fclose(fp);
     return 0;

}


OUTPUT:


#include

int main()
{
    FILE *fp;
    char ch;

    fp = fopen(__FILE__,"r");
    do
    {
        ch = getc(fp);
        putchar(ch);
     }
     while (ch != EOF);
     fclose(fp);
     return 0;
}


 

Comments