#include<stdio.h>
#include<conio.h>
# define swap(a,b) temp=a; a=b; b=temp;
void main( )
{
int i, j, temp;
i=5;
j=10;
temp=0;
if( i > j)
swap( i, j );
printf( "%d %d %d", i, j, temp);
}
Answers were Sorted based on User's Feedback
Answer / rohit751
Hi all...the main mistake in the program is using the semi
colons in the macro definition. Try this..
#include<stdio.h>
#include<conio.h>
# define swap(a,b) temp=a, a=b, b=temp;
void main( )
{
int i, j, temp;
i=5;
j=10;
temp=0;
if( i < j)
swap( i, j );
printf( "%d %d %d", i, j, temp);
}
Is This Answer Correct ? | 10 Yes | 0 No |
Answer / ashish rajvanshi
My dear frnds its a simple question
here the code of macro inserted in the program at the time of preprocessing and then the calculation will performed.
and then it will be calculated.
void main()
{
int i,j, temp;
i=5;
j=10;
temp=0;
if(i>j)
temp=a;
a=b;
b=temp;
printf("%d %d %d" , i , j , temp);
}
for further detail contect at(ashish.raj.mrt@gmail.com)
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / ashishrajvanshi01
On compiling i got ans 10, 0, 0. I did not understand the concept. Please expalin this to me.
Is This Answer Correct ? | 5 Yes | 4 No |
Answer / harish
it enters into swap function only when i>j.
but i contains 5 and j contains 10.
can u plz explain this
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / abhijeet
my frnd, C is dumb compiler. It doesn't know what actually
we mean.
Here, in this program, we have defined 1 macro. Ok
this macro wil be inserted and expanded into code.
this gives the unpredicted result. U try and find out what i
mean to say.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kumaravel
chance of providing answer is not possible. empty screen become view.
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manish soni tagore collage jai
my dear frd....
here some hapen.
#define swap(a,b) temp=a;a=b;b=temp;----------(1)
is was as function of swap two no;(but it is differnt frm
funtion.)
so
at i>j;
enter swap(i,j);
so jump at eq(n) ---(1) and call swap function'
and
temp=5;
i=10;
j=0;
you see three variable.
but it printf i,j to convert swap.
bcoz it have two arguments.
and print temp=0;
becoz temp have 0;
Is This Answer Correct ? | 0 Yes | 7 No |
What is putchar() function?
Is there a way to jump out of a function or functions?
When would you use a pointer to a function?
Explain how do you declare an array that will hold more than 64kb of data?
Is flag a keyword in c?
#‎include‬<stdio.h> void main() { int i; for(i=5;0;i++) { printf("%d",i); } }
what would be the output of the follwing struct st { char name[20]; int i; float f; }; main() { struct st emp = {"forum"}; printf("%d %f",emp.i,emp.f); }
what is the difference between exit() and _exit() functions?
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?
Explain how can I make sure that my program is the only one accessing a file?
Which of the following are valid "include" formats? A)#include and #include[file.h] B)#include (file.h) and #include C)#include [file.h] and #include "file.h" D)#include <file.h> and #include "file.h"
write a recursive program in'c'to find whether a given five digit number is a palindrome or not