C Language

May 20, 2023

How to use interchange comma operator in c language

program to use interchange comma operator in c language


 #include<stdio.h>
int main()
{
    int c=5,d=6,temp;
    printf("c=%d, d=%d\n",c,d);
    temp=c,c=d,d=temp;
    printf("c=%d, d=%d\n",c,d);
    return 0;
}

output


c=5, d=6
c=6, d=5

Steps Description

  1. Declare integer three variable c , d and temp
  2. initialize in integer variable c = 5 , d =6
  3. printf inbuild function display variable c and d with decimal placeholder %d
  4. Assign temp variable with variable c value
  5. Assign variable d value with temp variable
  6. printf inbuild function display variable c and variable d with decimal placeholder %d

by : Ajaj Khan

Quick Summary:

use interchange comma operator in c language