7-Write a C program to swap the two numbers without using third variable.

Program: 7

Write a C program to swap the two numbers without using third variable.

#include
#include
void main()
{
    int a, b , c;
    printf("Enter the value of a: ");
    scanf("%d", &a);
    printf("Enter the value of b: ");
    scanf("%d", &b);
    c=a;
    a=b;
    b=c;
    printf("The value of a is: %d\n", a);
    printf("The value of b is: %d", b);
    getch();
}
Output
Enter the value of a: 56

Enter the value of b: 31

The value of a is: 31

The value of b is: 56

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.