Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a program to swap two variables a=5 , b= 10 without
using third variable

Answers were Sorted based on User's Feedback



write a program to swap two variables a=5 , b= 10 without using third variable..

Answer / nagendra kumar

#include<stdio.h>
main(){
int a,b;

printf("Enter A value: ");
scanf("%d",&a);

printf("\nEnter B value: ");
scanf("%d",&b);


printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);

a=a+b;
b=a-b;
a=a-b;

printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}

Is This Answer Correct ?    20 Yes 4 No

write a program to swap two variables a=5 , b= 10 without using third variable..

Answer / dhanalakshmi

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("enter the a value"));
scanf("%d",&a);//a=10
printf("enter the b value");
scanf("%d",&b);//b=5
b=b+a;
a=b-a;
b=b-a;
printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}

Is This Answer Correct ?    7 Yes 2 No

write a program to swap two variables a=5 , b= 10 without using third variable..

Answer / samruthi

#include<stdio.h>
void main()
{
int a=5,b=10;
printf("The value of A is:%d",a);
printf("\n The value of B is:%d",b);
b=a;
a=b;
a=b+a;

printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
getch();
}

Is This Answer Correct ?    10 Yes 7 No

write a program to swap two variables a=5 , b= 10 without using third variable..

Answer / nagendra kumar

#include<stdio.h>
main(){
int a,b;

printf("Enter A value: ");
scanf("%d",&a);

printf("\nEnter B value: ");
scanf("%d",&b);


printf("\nThe value of A is:%d",a);
printf("\n The value of B is:%d",b);

a=(a+b)-(b=a);

printf("\n The value of A is:%d",a);
printf("\n The value of B is:%d",b);
}

Is This Answer Correct ?    4 Yes 2 No

write a program to swap two variables a=5 , b= 10 without using third variable..

Answer / shafi.shaik

main()
{
int a,b;
clrscr();
printf("enter a, b Value");
scanf("%d%d",&a,&b);
printf("\n%d",a);
printf("\n%d",b);
b=b-a;
a=a+b;
b=a-b;
printf("\n%d",a);
printf("\n%d",b);
getch();
}

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More C Interview Questions

FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

0 Answers   Wilco,


What is function pointer and where we will use it

2 Answers   Infosys, NetApp,


how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?

0 Answers  


Is c dynamically typed?

0 Answers  


how we can make 3d venturing graphics on outer interface

1 Answers   Microsoft,


why integer range between -327680to+32767

2 Answers  


Tell me when would you use a pointer to a function?

0 Answers  


what is difference between C and C++

4 Answers  


How can you increase the size of a statically allocated array?

0 Answers   TISL,


What are the types of operators in c?

0 Answers  


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

0 Answers  


What is the difference between declaring a variable and defining a variable?

0 Answers  


Categories