0
0
Cprogramming~15 mins

Relational operators in C - Mini Project: Build & Apply

Choose your learning style9 modes available
Relational Operators in C
📖 Scenario: You are creating a simple program to compare ages of two friends to see who is older.
🎯 Goal: Build a C program that uses relational operators to compare two age values and prints the comparison results.
📋 What You'll Learn
Create two integer variables named age1 and age2 with exact values 25 and 30
Create an integer variable named isOlder to store the result of the comparison
Use the relational operator > to check if age1 is greater than age2
Print the value of isOlder to show the comparison result
💡 Why This Matters
🌍 Real World
Comparing values is common in programs that make decisions, like checking ages, prices, or scores.
💼 Career
Understanding relational operators is essential for writing conditions in software development, testing, and data validation.
Progress0 / 4 steps
1
Create age variables
Create two integer variables called age1 and age2 with values 25 and 30 respectively.
C
Need a hint?

Use int to declare variables and assign the exact values.

2
Create comparison variable
Create an integer variable called isOlder to store the result of comparing if age1 is greater than age2.
C
Need a hint?

Declare isOlder as an integer without assigning a value yet.

3
Compare ages using relational operator
Assign to isOlder the result of the expression age1 > age2 using the relational operator >.
C
Need a hint?

Use the relational operator > to compare age1 and age2.

4
Print the comparison result
Use printf to print the value of isOlder so the program shows 0 or 1 depending on the comparison.
C
Need a hint?

Use printf("%d\n", isOlder); to print the integer value with a new line.