Program: 56
Write a c program to swap two numbers without using third variables | Let Us C Solutions
#include<stdio.h> int main() { int C, D, T; printf("Enter the value of C: "); scanf("%d", &C); printf("Enter the value of D: "); scanf("%d", &D); C = C+D; //c=30, d=20 D = C-D; //d=10, c=30 C = C-D; //c=20 printf("\n The value of C: %d", C); printf("\n The value of D: %d", D); getch(); }
Output:
Enter the value of C: 10 Enter the value of D: 20 The value of C: 20 The value of D: 10
Leave a Comment