Sunday, December 23, 2018

PROGRAM TO SWAP TWO NUMBERS

/*PROGRAM  TO  SWAP  TWO  NUMBERS*/

#include<stdio.h>
#include<string.h>
#include<malloc.h>
#include<conio.h>
void main()
{
char first[100], second[100], *temp;
clrscr();
printf("Enter the first string\n");
gets(first);
printf("Enter the second string\n");
gets(second);
printf("\nBefore Swapping\n");
printf("First string: %s\n",first);
printf("Second string: %s\n\n",second);
temp = (char*)malloc(100);
strcpy(temp,first);
strcpy(first,second);
strcpy(second,temp);
printf("After Swapping\n");
printf("First string: %s\n",first);
printf("Second string: %s\n",second);
 getch();
}

OUTPUT:-
sk.

No comments:

Post a Comment

Wikipedia

Search results

Search The program