Answers for "write a c program to swap of two numbers using functions."

0

swapping of two numbers in c without temporary variable

#include<stdio.h>  
void main()    
{    
int a=10, b=20;      
printf("Before swap a=%d b=%d",a,b);      
a=a+b;   
b=a-b;   
a=a-b;   
printf("\nAfter swap a=%d b=%d",a,b);      
}
Posted by: Guest on April-05-2022
0

c program for swapping of two numbers using temporary variable

#include <stdio.h>
int main()
{
    int a, b, temp;
    printf("enter the values of a and b: \n");
    scanf("%d%d", &a, &b );
    printf("current values are:\n a=%d\n b=%d\n", a, b);
    temp=a;
    a=b;
    b=temp;
    printf("After swapping:\n a=%d\n b=%d\n", a, b);
}
Posted by: Guest on April-19-2021
0

C Programming to swap two variables

#include <stdio.h>

int main()
{
    int x = 20, y = 30, temp;
    temp = x;
    x = y;
    y = temp;
    printf("X = %d and Y = %d", x, y);
    
    return 0;
}
Posted by: Guest on June-28-2021

Code answers related to "write a c program to swap of two numbers using functions."

Browse Popular Code Answers by Language