Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

If Statement Homework Help

Syntax is as follow:

if (condition)
{
Statements to be executed;
}

If the condition is true then only the statement will be executed.

Following expressions are used in the condition:

x = = y if x is equal to y
x ! = y if x is not equal to y
x > y if x is greater than y
x >= y if x is greater than or equal to y
x < y if x is less than y
x <= y if x is less than or equal to y

Note that, here = = sign is used for the comparison not = sign.

Example of If Statement:

#include <stdio.h>
#include <conio.h>
void main()
{
int i;
printf(“Enter an integer: ”);
scanf(“%d”,&i);

if (i<=0)
{
printf(“\nYou have entered a non-positive integer”);
}
return;
}

In C any non-zero quantity is considered as true. Now look at following examples:

if (10)
{
printf(“This statement will be executed”);
}

In the above example, the statement within () is 10, which is true since it is non zero, hence the statement will be executed.


If Statement Homework Help

Topics in C Programming

Copyright © 2009-2023 UrgentHomework.com, All right reserved.