Write a program to read three variable x, y and z.use conditional statement and evaluate values of variable a,b and c.Check the sums for equality and print different message.

c
#include<stdio.h>
#include<conio.h>
main()
{
	int x,y,z,a,b,c,m,n;
	printf("Enter values of x,y,z:- ");
	scanf("%d %d %d", &x,&y,&z);
	a=(x>=5 ? 3 : 4);
	printf("\n Calculated value of a is:-%d",a);
	b=(y<=8 ? 10 : 9);
	printf("\n Calulated value of b is:-%d",b);
	c=(z==10 ? 20 : 30);
	printf("\n Calulated value of c is:-%d",c);
	m=x+y+z;
	n=a+b+c;
	printf("\n Addition of x,y,z is %d (m)",m);
	printf("\n Addition of a,b,c is %d (m)",n);
	printf("\n %s", m!=n ? "m & n not equal" : "m & n are equal");
	getch();
	
}

/*The sum of x y and z is stored in m and the sum of a b and c stored in n,The variable m and n are 
compared and appropriate messages are displayed*/

This program reads in three variables, x, y, and z, from the user and calculates the values of three other variables, a, b, and c, using conditional statements. The values of a, b, and c are determined based on the values of x, y, and z. If x is greater than or equal to 5, then a is assigned the value of 3, otherwise, it is assigned 4. If y is less than or equal to 8, then b is assigned the value of 10, otherwise, it is assigned 9. If z is equal to 10, then c is assigned the value of 20, otherwise, it is assigned 30.

The sum of x, y, and z is stored in the variable m, and the sum of a, b, and c is stored in the variable n. Then, the values of m and n are compared using the != operator, and a message is displayed indicating if they are equal or not equal. The program ends with the use of the getch() function to wait for a user to press a key to end the program.

Thanks

Write a program to read three variable x, y and z.use conditional statement and evaluate values of variable a,b and c.Check the sums for equality and print different message.

Leave a Reply

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

Scroll to top