Headlines
Loading...
C program to swap 2 strings

C program to swap 2 strings

Write a c program to swap 2 strings.

#include<stdio .h="">
#include<conio .h="">
#include<string .h="">
void main()
{
 char s1[20], s2[20], temp[20];
 clrscr();
 printf("Enter 1st String : ");
 gets(s1);
 printf("Enter 2nd String : ");
 gets(s2);
 strcpy(temp,s1);
 strcpy(s1,s2);
 strcpy(s2,temp);
 printf("\nString after Swapping :);
 printf("\nString1 : %s",s1);
 printf("\nString2 : %s",s2);
 getch();

}


/*Output
Enter 1st String : Microsoft OS
Enter 2nd String : Intel Processor

Strings after Swapping :
String1 : Intel Processor
String2 : Microsoft OS
*/</string></conio></stdio>
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***