#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

Can you think of a logic behind the game minesweeper.

1979


Given a valid 24 hour format time find the combination of the value and write a program ,do not hard the value and if any other inputs provided should work with the logic implemented Input: 11:30 Output: 13:10 Input: 18:25 Output: 21:58

1086


If null and 0 are equivalent as null pointer constants, which should I use?

556


Can you add pointers together? Why would you?

618


how to write optimum code to divide a 50 digit number with a 25 digit number??

2724






What is a char in c?

534


Why flag is used in c?

629


What is return type in c?

614


Explain continue keyword in c

554


Write a program to swap two numbers without using third variable?

791


Explain indirection?

615


Is c object oriented?

518


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

639


Why do we use int main?

576


How can I sort more data than will fit in memory?

600