You have enter wrong datatype when comparing the choice (int type) with a string text. In C/C++ unlike dynamic programming language, you cannot compare int with strings without properly converting either of them. You use strcpy for comparing string and == for comparing int.

Then your programming will run.

Answer from Khalid Ahmad Nori on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ c-if-statement
C - if Statement - GeeksforGeeks
July 23, 2025 - Explanation: The first if statement have a condition that checks if n is smaller than 10. For n = 9, this evaluated to true, so the code inside this if statement body is executed.
๐ŸŒ
Cprogramming
cprogramming.com โ€บ tutorial โ€บ c โ€บ lesson2.html
If Statements in C - Cprogramming.com
How to begin Get the book ยท C tutorial C++ tutorial Game programming Graphics programming Algorithms More tutorials
People also ask

How to use an if statement in C?
To use an if statement in C, write a condition inside parentheses after the if keyword. If the condition is true, the code inside the curly braces {} executes.
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ c-programming โ€บ if-statement
If Statement in C Language (Syntax, Examples, Use)
Why do we use if statement in C?
We use the if statement in C to introduce decision-making in programs, allowing them to handle different scenarios dynamically.
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ c-programming โ€บ if-statement
If Statement in C Language (Syntax, Examples, Use)
Can an if statement have multiple conditions in C?
Yes, multiple conditions can be combined using logical operators like && (AND) or || (OR).
๐ŸŒ
wscubetech.com
wscubetech.com โ€บ resources โ€บ c-programming โ€บ if-statement
If Statement in C Language (Syntax, Examples, Use)
๐ŸŒ
ScholarHat
scholarhat.com โ€บ home
If Statements in C: Syntax, Examples, and Best Practices
July 29, 2025 - When using the if statement, 'condition' is something the computer evaluates. If it's true, the code inside the curly braces is executed. If it's false, the code inside the braces is skipped. ... Condition Checking- Firstly, you need to write the โ€˜ifโ€™ keyword followed by a condition inside the parenthesis. This condition is like a question the program will ask itself. Making a Decision- If the condition turns out to be true, meaning the answer to the question is โ€œyesโ€, the code inside the curly braces โ€˜{}โ€™ following the โ€˜ifโ€™ statement is executed.
๐ŸŒ
IncludeHelp
includehelp.com โ€บ c-programs โ€บ c-if-else-aptitude-questions-and-answers.aspx
C If else (Conditional Statements) Aptitude Questions and Answers - IncludeHelp
#include <stdio.h> #define TRUE 1 int main() { if(TRUE) printf("1"); printf("2"); else printf("3"); printf("4"); return 0; } ... Correct Answer - 1 ERROR : misplaced if/illegal else without matching if. You can use only one statement within the if( )without parenthesis {...} .
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_conditions.php
C If ... Else Conditions
In the example above we use two variables, x and y, to test whether x is greater than y (using the > operator). As x is 20 and y is 18, the condition is true, so the program prints "x is greater than y". Since the condition in an if statement must be either true or false, you can store the result in a boolean variable instead of writing the comparison directly:
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ if_statement_in_c.htm
C - The If Statement
If the Boolean expression evaluates to false, then the first set of code after the end of the if statement (after the closing curly brace) will be executed. C programming treats any non-zero and non-null values as true.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ decision-making-in-c
Decision Making in C (if , if..else, Nested if, if-else-if ) - GeeksforGeeks
The if statement alone tells us that if a condition is true, it will execute a block of statements and if the condition is false, it wonโ€™t. But what if we want to do something else when the condition is false? Here comes the C else statement. We can use the else statement with the if statement to execute a block of code when the condition is false.
Published ย  November 7, 2025
๐ŸŒ
Sanfoundry
sanfoundry.com โ€บ c-programming-questions-answers-if-then-else-statements
If-then-else Statement - C Programming Questions and Answers - Sanfoundry
December 31, 2025 - This set of C Multiple Choice Questions & Answers (MCQs) focuses on โ€œIf-then-else Statements โ€“ 1โ€. Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial. 1. What will be the output of the following C code? ... Answer: a Explanation: Since x is initialized to 5, For first if block x > 1 means 5 < 1 is true, so this block skipped.
๐ŸŒ
WsCube Tech
wscubetech.com โ€บ resources โ€บ c-programming โ€บ if-statement
If Statement in C Language (Syntax, Examples, Use)
3 weeks ago - Learn in this tutorial about the if statement in C, including its syntax, examples, and practical use cases. Also, understand its benefits and common mistakes.
๐ŸŒ
w3resource
w3resource.com โ€บ c-programming-exercises โ€บ conditional-statement โ€บ index.php
C programming exercises: Conditional Statement - w3resource
This resource offers a total of 130 C Conditional Statement problems for practice. It includes 26 main exercises, each accompanied by solutions, detailed explanations, and four related problems.
๐ŸŒ
Aticleworld
aticleworld.com โ€บ home โ€บ if else in c, some important programming exercises
if else in c, some important programming exercises - Aticleworld
August 17, 2022 - In this blog post, you will see ... nested if..else). if and if-else in C is a selection statement that is used to select statements depending on the value of a controlling expression....
๐ŸŒ
Programiz
programiz.com โ€บ c-programming โ€บ c-if-else-statement
C if...else Statement
When the user enters 5, the test ... optional else block. The syntax of the if..else statement is: if (test expression) { // run code if test expression is true } else { // run code if test expression is false }...
๐ŸŒ
Sankalandtech
sankalandtech.com โ€บ Tutorials โ€บ C โ€บ conditional-mcq-c.html
MCQ on conditional statements in C langguage!
Explanation: The nested if-else statement works the similar way: if the given condition evaluates true then the if block is executed. If false, the else block is executed. This nesting can be several levels deep, with each level having its own if-else logic. The execution does not have to be ...
Top answer
1 of 3
6

Remove semi-colon

remove semi-colon this lines

if (&radius > -1);  {  

should be

if (radius > -1)  {

Should do this for easier tracking if-else statement

change these lines

printf("Area = %d\n", area);}

return(0); }

to

printf("Area = %d\n", area);
}

return(0); 
}

Here is style for if-else statement, I think it's easier for you to track your code

if (condition) {
    statements;
} 
else if (condition) { 
    statements;
}
else {
    statements;
}
2 of 3
1

The C compiler doesn't care about formatting, in theory you can do whatever you like, and there's no consensus for what is/isn't "proper formatting".

However, most programmers stick to a specific style so that it's easier to read the source code; and if you're working in a team then it's nice if all programmers on the team use the same style so that all of the source code is consistent. To achieve that, there may be a formal "style guide", and if there is you should follow it.

Beyond that, there are some common rules that almost everyone follows:

  • nested blocks that are delimited by braces are indented somehow (with either "N space characters" or "N tab characters") relative to the parent block

  • cases of a switch statements will be exceptions to the indentation rules. Typically each case's statements are indented even though there's no braces; and the case keyword itself may or may not be indented by the parent switch's braces.

  • either all braces are always on a line by themselves; or starting braces are at the end of the line and ending braces may be at the start of a line containing a related statement

  • when a block consists of a single statement; either it always uses braces and is takes up a line by itself, or it never uses braces and shares the same line as its parent.

  • the else if pair is always an exception to the "block consists of a single statement" rule (the if is a single statement that is never treated as a separate block, and people pretend else if is a single elseif keyword).

What this means is that (depending on who got their way when arguing about it) this might acceptable:

int main() {
    int area;

    printf("Enter radius: ");
    scanf("%d", &radius);

    switch(radius) {
    case 0:
        return 0;
    case 1:
        return 1;
    }

    if (&radius > -1) {
        area = (int)(3.14159 * radius * radius);
        printf("Area = %d\n", area);
    } else return -1;
    return area;
}

..and this might also be acceptable:

int main()
{
    int area;

    printf("Enter radius: ");
    scanf("%d", &radius);

    switch(radius)
    {
        case 0:
            return 0;
        case 1:
            return 1;
    }

    if (&radius > -1)
    {
        area = (int)(3.14159 * radius * radius);
        printf("Area = %d\n", area);
    }
    else
    {
        return -1;
    }
    return area;
}
๐ŸŒ
Quora
quora.com โ€บ What-are-some-examples-of-if-statements-in-C-programming
What are some examples of if statements in C programming? - Quora
To create a condition we have if, else if and finally else statements. The first two allows us to check for different conditions, the last one is like a default in case no other condition has been met. We can have as many else if as we want. You can also use a switch which does exactly the same. Letโ€™s take a look at an example of a movie theatre pricing: ... To add to current answers that perfectly explain what an if statement is, here is my contribution.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ cpp โ€บ c-language โ€บ if-statement-c
if Statement (C) | Microsoft Learn
January 25, 2023 - With both forms, control then passes from the if statement to the next statement in the program unless one of the statements contains a break, continue, or goto. ... In this example, the statement y = x/i; is executed if i is greater than 0. ...
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2014 โ€บ 01 โ€บ c-if-statement
If statement in C programming with example
September 23, 2017 - if (condition) { //Block of C statements here //These statements will only execute if the condition is true } #include <stdio.h> int main() { int x = 20; int y = 22; if (x<y) { printf("Variable x is less than y"); } return 0; } ... Explanation: The condition (x<y) specified in the โ€œifโ€ ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ cprogramming โ€บ if_else_statement_in_c.htm
C - The if-else Statement
The else keyword helps you to provide an alternative course of action to be taken when the Boolean expression in the if statement turns out to be false. The use of else keyword is optional; it's up to you whether you want to use it or not. ... The C compiler evaluates the condition, and executes a statement or a block of statements following the if statement if it is true.