C program to run the body of if condition as well as body of else condition
First program (using goto)
#include<conio.h>
void main()
{
if(1)
{
printf("Hi Mayank");
goto A;
}
else
{
A:
printf("\nShekhar ");
for(int i=1;i<11;i++)
printf("%d ",i);
}
getch();
}
Output : Hi Mayank
Shekhar 1 2 3 4 5 6 7 8 9 10
#include<conio.h>
#define else if(1)
void main()
{
if(1)
{
printf("Hi Mayank");
}
else
{
for(int i=1;i<11;i++)
printf("%d ",i);
}
getch();
}
Output : Hi Mayank
Shekhar 1 2 3 4 5 6 7 8 9 10
First program (using goto)
#include<stdio.h>
#include<conio.h>
void main()
{
if(1)
{
printf("Hi Mayank");
goto A;
}
else
{
A:
printf("\nShekhar ");
for(int i=1;i<11;i++)
printf("%d ",i);
}
getch();
}
Output : Hi Mayank
Shekhar 1 2 3 4 5 6 7 8 9 10
Second program (using macro)
#include<stdio.h>
#include<conio.h>
#define else if(1)
void main()
{
if(1)
{
printf("Hi Mayank");
}
else
{
printf("\nShekhar ");
for(int i=1;i<11;i++)
printf("%d ",i);
}
getch();
}
Output : Hi Mayank
Shekhar 1 2 3 4 5 6 7 8 9 10
No comments:
Post a Comment