Program Without Semicolon " ; "

This is a simple  Program in C to print output without using a semi-colon " ; ". This is a part of Mumbai University MCA Colleges. 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.

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment