Program in C to print output without using a semi-colon " ; ". It is mostly asked in Interviews.

Ram Pothuraju


This is a simple  Program in C to print output without using a semi-colon " ; ". It is mostly asked in Interviews.






Print without Semi-Colon ";"
Method 1 :-
#include<stdio.h>
#include<conio.h>

void main()
{
 if(printf("Programs and notes for mca!"))
{ }
}

In this program we use the function printf() with in the if statement to produce the output without ";".
The printf() function will return the length of the string within the if and will get executed.

Points to note here is that we have written a output statement within if.
This same logic can be used for other programming languages as well.


Method 2 :-
#include <stdio.h>
#include<conio.h>

#define m ;
void main()
{
 clrscr()m
 printf("Programs and notes for mca")m
}

How this isnt really the solution.

What we have done here is that we have used the #define directive to represent the semicolon as "a".
So where ever we have to use a semicolon we can replace it with a.

Post a Comment

0Comments

Post a Comment (0)