Write a program to show the effect of increment operator as a prefix.

prefix
#include<stdio.h>
#include<conio.h>
main()
{
	int a,z,x=10,y=30;
	z=x*++y;      //++ before y is called prefix//
	a=x*y;
	printf("\n %d %d",z,a);
	getch();
}


/*Y gets first incremented and the equations are solved,
Both the equation give the same result 310*/

The program demonstrates the effect of the increment operator as a prefix. The program declares and initializes the variables x and y with the values 10 and 30 respectively. Then, the program calculates the value of z by multiplying x with the incremented value of y. After that, it calculates the value of a by multiplying x with the current value of y. Finally, the program prints the values of z and a using the printf function. The output of the program will be 310 310.

Thanks

Write a program to show the effect of increment operator as a prefix.

Leave a Reply

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

Scroll to top