Write a program to illustrate the use of comma operator.

coma opretors
#include<stdio.h>
#include<conio.h>
main()
{
	printf("Addition =%d \n Subtraction =%d",2+3,5-4);
	getch();
}


/*Comma operator:-
The comma operator is used to separate two or more expressions
In the mentioned program the two equations are separated by commas.*/

The program demonstrates the use of the comma operator to separate two expressions. The two expressions, 2 + 3 and 5 - 4, are separated by a comma in the printf function. The first expression evaluates to 5 and the second expression evaluates to 1. These values are then printed to the console, with the string “Addition =%d \n Subtraction =%d” specifying the format for the output. The format specifier %d specifies that the value should be printed as an integer.

Thanks

Write a program to illustrate the use of comma operator.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top