Horje
swap two numbers in c Code Example
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);
}
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;
}
Source: devsenv.com
swap two numbers in c
#include<stdio.h>

void swapping(int, int);  //function declaration
int main()
{
    int a, b;

    printf("Enter values for a and b respectively: \n");
    scanf("%d %d",&a,&b);

    printf("The values of a and b BEFORE swapping are a = %d & b = %d \n", a, b);

    swapping(a, b);      //function call
    return 0;
}

void swapping(int x, int y)   //function definition
{
    int third;
    third = x;
    x    = y;
    y    = third;

    printf("The values of a and b AFTER swapping are a = %d & b = %d \n", x, y);
}




C

Related
set all pins as input for loop Code Example set all pins as input for loop Code Example
kubernetes cheat sheet Code Example kubernetes cheat sheet Code Example
c program for fibonacci series Code Example c program for fibonacci series Code Example
Program to Check Whether Character is Lowercase or Not without using islower function Code Example Program to Check Whether Character is Lowercase or Not without using islower function Code Example
arduino server read Code Example arduino server read Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8