a C prog to swap 2 no.s without using variables just an
array?

Answers were Sorted based on User's Feedback



a C prog to swap 2 no.s without using variables just an array?..

Answer / laxmi bose

#include<stdio.h>
main()
{
int a[0],a[1],a[2];
scanf("%d%d",&a[0],&a[1]);
a[2]=a[0];
a[0]=a[1];
a[1]=a[2];
printf("%d,%d",a[0],a[1]);
}

Is This Answer Correct ?    11 Yes 0 No

a C prog to swap 2 no.s without using variables just an array?..

Answer / sankar kiran

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter the number:");
scanf("%d%d",&a,&b)
a=a+b;
b=a-b;
a=a-b;
printf("%d%d",a,b);
getch();

}

Is This Answer Correct ?    14 Yes 7 No

a C prog to swap 2 no.s without using variables just an array?..

Answer / jaspreet singh

void main()
{
int a[2]={20,10};
a[0]=a[0]^a[1];
a[1]=a[0]^a[1];
a[0]=a[0]^a[1];
printf("a=%d,b=%d",a[0],a[1])
getch();
}

Is This Answer Correct ?    7 Yes 4 No

a C prog to swap 2 no.s without using variables just an array?..

Answer / karthik

void main()
{
int a=10,b=20;
a^=b^=a^=b;
printf("a=%d,b=%d",a,b)
getch();
}

Is This Answer Correct ?    8 Yes 6 No

a C prog to swap 2 no.s without using variables just an array?..

Answer / baidyanath bisoyi

void main()
{
int a,b;
printf("enter the two numbers\n");
scanf("%d%d",&a,&b);
printf("a=%d\n b=%d\n",a,b);
a=a+b-(b=a);
printf("a=%d\n b=%d\n",a,b);
getch();
}

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Interview Questions

can we print any string in c language without using semicolon(;)(terminator) in whole program.

11 Answers  


Why c++ is called c++ and not c+?

9 Answers   EBS,


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

0 Answers  


To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9

0 Answers   HCL,


What is Full Form of C and Why We use C

23 Answers  






What is the difference between typedef struct and struct?

0 Answers  


Why c is called top down?

0 Answers  


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

0 Answers   Infosys,


Write a program to print factorial of given number using recursion?

0 Answers  


write a progrmm in c language take user interface generate table using for loop?

0 Answers  


What's the difference between a linked list and an array?

14 Answers  


4. main() { int c=- -2; printf("c=%d",c); }

0 Answers  


Categories