#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
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
How is a macro different from a function?
What do you mean by a local block?
to find the closest pair
What are the preprocessor categories?
What does malloc () calloc () realloc () free () do?
Why c is a procedural language?
What are the similarities between c and c++?
Write a c program to demonstrate character and string constants?
Explain the ternary tree?
When was c language developed?
Write a program to generate random numbers in c?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Write a program of advanced Fibonacci series.
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]