Skip to content
Solved Examples · Example 10

Q.​2) Write a C program to compare two values.
#include<stdio.h>  
void main()  
{  
    float m=3.234, n=0.0546;  
    if(m>n)  
        printf("m is greater than n\n");  
}  

Karnataka PUCTextbookLong· 3mImportance★★★★★est
32% · 49/154 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

[!TLDR]

The > operator compares two float values; here m is larger than n, so the if condition is true and the message is printed.

Relational operators also work on real (float) values. The operator > gives true (1) when its left operand is greater than its right operand, otherwise false (0). With m = 3.234 and n = 0.0546, the condition m>n is true, so the printf inside the if runs. A complete standard version is:

#include <stdio.h>

int main(void)
{
    float m = 3.234, n = 0.0546; …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.