#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);
}

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon

1730


How is a macro different from a function?

652


What do you mean by a local block?

625


to find the closest pair

1816


What are the preprocessor categories?

633






What does malloc () calloc () realloc () free () do?

554


Why c is a procedural language?

578


What are the similarities between c and c++?

593


Write a c program to demonstrate character and string constants?

1677


Explain the ternary tree?

595


When was c language developed?

697


Write a program to generate random numbers in c?

658


Why is it usually a bad idea to use gets()? Suggest a workaround.

894


Write a program of advanced Fibonacci series.

704


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

623