#include <stdio.h>
#include <stdbool.h>
int main() {
// Arithmetic Operators
int x = 10;
int y = 5;
int sum = x + y; // Addition
int difference = x - y; // Subtraction
int product = x * y; // Multiplication
int quotient = x / y; // Integer Division
int remainder = x % y; // Modulus (Remainder)
double power = pow(x, y); // Exponentiation
printf("Sum: %d\n", sum);
printf("Difference: %d\n", difference);
printf("Product: %d\n", product);
printf("Quotient: %d\n", quotient);
printf("Remainder: %d\n", remainder);
printf("Power: %f\n", power);
// Comparison Operators
bool isGreater = x > y; // Greater Than
bool isEqual = x == y; // Equal To
bool isNotEqual = x != y; // Not Equal To
bool isLessThan = x < y; // Less Than
bool isGreaterOrEqual = x >= y; // Greater Than or Equal To
bool isLessOrEqual = x <= y; // Less Than or Equal To
printf("Is x Greater Than y? %d\n", isGreater);
printf("Is x Equal To y? %d\n", isEqual);
printf("Is x Not Equal To y? %d\n", isNotEqual);
printf("Is x Less Than y? %d\n", isLessThan);
printf("Is x Greater Than or Equal To y? %d\n", isGreaterOrEqual);
printf("Is x Less Than or Equal To y? %d\n", isLessOrEqual);
// Logical Operators
bool a = true;
bool b = false;
bool andResult = a && b; // AND
bool orResult = a || b; // OR
bool notResult = !a; // NOT
printf("AND Result: %d\n", andResult);
printf("OR Result: %d\n", orResult);
printf("NOT Result: %d\n", notResult);
// Assignment Operators
int z = 5;
z += 10; // Addition Assignment
z -= 2; // Subtraction Assignment
z *= 3; // Multiplication Assignment
z /= 2; // Division Assignment
z %= 3; // Modulus (Remainder) Assignment
printf("Z: %d\n", z);
// Ternary Operator
int p = 10;
int q = (p > 5) ? 1 : 0; // If p is greater than 5, q is assigned 1. Otherwise, q is assigned 0.
printf("Q: %d\n", q);
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: