A program to swap the value of two variable without using third variable.
#include <stdio.h>
#include <conio.h>
void main(){
int a,b; // Defining two variables.
printf("Enter the value of a, b"); //Printing the statement.
scanf("%d%d",&a,&b); //Getting the value of a,b from user.
a=a+b;
b=a-b;
a=a-b;
printf("The value of a: %d\nThe value of b: %d"); //Printing the swap value.
getch();
}
#include <stdio.h>
#include <conio.h>
void main(){
int a,b; // Defining two variables.
printf("Enter the value of a, b"); //Printing the statement.
scanf("%d%d",&a,&b); //Getting the value of a,b from user.
a=a+b;
b=a-b;
a=a-b;
printf("The value of a: %d\nThe value of b: %d"); //Printing the swap value.
getch();
}
No comments:
Post a Comment