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...


How to write a program for swapping two strings without
using 3rd variable and without using string functions.

Answers were Sorted based on User's Feedback



How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / sivaraj

Questions is to swap the string not for integers so the
above answers are wrong.

Is This Answer Correct ?    47 Yes 7 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / gaurav rustagi

#include <iostream>
#include <string.h>
using namespace std;
void swap ( char ** , char ** ) ;
int main ()
{
char * buyer= "US Dollars" ;
char * seller = "IN Ruppees" ;

cout << "Before swap, buyer has " << buyer;
cout << " and seller has " << seller << endl;

swap (buyer,seller);

cout << " After swap, buyer has " << buyer;
cout << " and seller has " << seller << endl;

return 0;
}
void swap ( char ** L , char ** R )
{
char ** temp = R;
R = L ;
L = temp ;
}

Is This Answer Correct ?    7 Yes 13 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / sri

main()
{
int a=5,b=3;
a=a+b;
b=a-b;
a=a-b;
printf(" %d %d ",a,b);
getch();
}

Is This Answer Correct ?    33 Yes 42 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / biswambar

main()
{
int a=5,b=3;
b=a+b;
a=b-a;
b=b-a;
printf(" %d %d ",a,b);
}

Is This Answer Correct ?    44 Yes 54 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / saptarshi

void main()
{
char *p="string1";
char *q="string2";

p^=q^=p^=q;
printf("%s,%s",p,q);
}

swapping the base pointers of the two strings may work...
if they are declared as character arrays, then it is not
possible as we cannot modify the value of array base
pointers...

Is This Answer Correct ?    10 Yes 26 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / ramu pasupuleti

#include<stdio.h>
#include<conio.h>
{
printf("enter a,b values");
a=a+b;
a=a-b;
b=a-b;
printf("%d%d",a,b);
getch();
}

Is This Answer Correct ?    2 Yes 18 No

How to write a program for swapping two strings without using 3rd variable and without using strin..

Answer / srinath, hyd

main()
{
int a=5,b=3;
a=a+b;
b=a-b;
a=a-b;
printf(" %d %d ",a,b);
getch();
}

Is This Answer Correct ?    7 Yes 26 No

Post New Answer

More C Interview Questions

application attempts to perform an operation?

0 Answers  


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

0 Answers  


enum DAY { sunday, monday, tuesday }; enum EDAYS { friday, saturday, sunday }; void main() { int i =0; if( i == sunday) { printf("%d",i); } } what would be the output?

4 Answers   TCS,


What is the function of this pointer?

0 Answers   Agilent, ZS Associates,


Why is main function so important?

0 Answers  


wat is the output #define VOLEDEMORT _who_must_not_be_named int main() { printf("VOLEDEMORT"); }

2 Answers  


what is c?

4 Answers   IBM, TCS,


how we can make 3d venturing graphics on outer interface

1 Answers   Microsoft,


When c language was developed?

0 Answers  


how can use subset in c program and give more example

0 Answers  


How can I do serial ("comm") port I/O?

0 Answers   Celstream,


All technical questions

0 Answers   TCS,


Categories