40-Write a program to swap the two numbers using function.

Program: 40

Write a program to swap the two numbers using function.

#include
#include
int swap(int x, int y);
void main()
{
    int a, b;
    printf("Enter the value of a= ");
    scanf("%d", &a);
    printf("Enter the value of b= ");
    scanf("%d", &b);
    swap(a, b);
    getch();
}
int swap(int x, int y)
{
    int t;
    t=x;
    x=y;
    y=t;
    printf("\n\nThe value of a is %d.\n", x);
    printf("The value of b is %d.\n", y);
}
Output
Enter the value of a= 6

Enter the value of b= 54

The value of a is 54.

The value of b is 6.

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.