Posts

Showing posts with the label Swapping

Swapping of Two number

Image
C Program to Swapping of Two number #include<conio.h> #include<stdio.h> void main() {     int num1,num2,temp=0;     clrscr();     printf("Enter first number : ");     scanf("%d",&num1);     printf("Enter second number : ");     scanf("%d",&num2);     printf("\n\nValue of A: %d   and  Value of B: %d",num1,num2);     temp=num1;     num1=num2;     num2=temp;     printf("\n\n\n After swaping \n\n");     printf("Value of A: %d   and  Value of B: %d",num1,num2);     getch(); } out put

Swapping two number without 3rd variable

Image
C Program to Swapping two number without 3rd variable #include<conio.h> #include<stdio.h> void main() {     int num1,num2;     clrscr();     printf("Enter first number : ");     scanf("%d",&num1);     printf("Enter second number : ");     scanf("%d",&num2);     printf("\n\nValue of A: %d   and  Value of B: %d",num1,num2);     num1=num2+num1;     num2=num1-num2;     num1=num1-num2;     printf("\n\n\n After swaping \n\n");     printf("Value of A: %d   and  Value of B: %d",num1,num2);     getch(); } out put: