Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

I.

OPERATOR
Expression :

• An expression is anything which evaluates to something.


• Expressions are combinations of operators and operands.

Operator :
Operators are special symbols that perform specific operations on one, two, or three
operands, and then return a result.
Operator's Categories:

1. Unary : A unary operator is an operator, which operates on one operand.


2. Binary : A binary operator is an operator, which operates on two operands.
3. Ternary : A ternary operator is an operator, which operates on three operands.

We use the ternary operator in C to run one code when the condition is true and another code
when the condition is false. For example,

(age >= 18) ? printf("Can Vote") : printf("Cannot Vote");


Here, when the age is greater than or equal to 18, Can Vote is printed. Otherwise, Cannot
Vote is printed.

Syntax of Ternary Operator

The syntax of ternary operator is:

testCondition ? expression1 : expression 2;

The testCondition is a boolean expression that results in either true or false. If the condition
is
• true - expression1 (before the colon) is executed
• false - expression2 (after the colon) is executed
The ternary operator takes 3 operands (condition, expression1 and expression2). Hence, the
name ternary operator.

Example: C Ternary Operator


Run
#include <stdio.h>

int main() {

3
int age;

// take input from users


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

// ternary operator to find if a person can vote or not


(age >= 18) ? printf("You can vote") : printf("You cannot vote");

return 0;
} Code
Output 1

Enter your age: 12


You cannot vote

In the above example, we have used a ternary operator that checks whether a user can vote or
not based on the input value. Here,

• age >= 18 - test condition that checks if input value is greater or equal to 18
• printf("You can vote") - expression1 that is executed if condition is true
• printf("You cannot vote") - expression2 that is executed if condition is false
Here, the user inputs 12, so the condition becomes false. Hence, we get You cannot vote as
output.
Output 2

Enter your age: 24


You can vote

This time the input value is 24 which is greater than 18. Hence, we get You can vote as
output.

Assign the ternary operator to a variable

In C programming, we can also assign the expression of the ternary operator to a variable.
For example,

variable = condition ? expression1 : expression2;

3
Here, if the test condition is true, expression1 will be assigned to the variable.
Otherwise, expression2 will be assigned.

Let's see an example

#include <stdio.h>

int main() {

// create variables
char operator = '+';
int num1 = 8;
int num2 = 7;

// using variables in ternary operator


int result = (operator == '+') ? (num1 + num2) : (num1 - num2);

printf("%d", result);

return 0;
}

// Output: 15

Run Code
In the above example, the test condition (operator == '+') will always be true. So, the first
expression before the colon i.e the summation of two integers num1 and num2 is assigned to
the result variable.
And, finally the result variable is printed as an output giving out the summation of 8 and 7.
i.e 15.

Ternary Operator Vs. if...else Statement in C

In some of the cases, we can replace the if...else statement with a ternary operator. This will
make our code cleaner and shorter.
Let's see an example:

include <stdio.h>

int main() {
int number = 3;

if (number % 2 == 0) {

3
printf("Even Number");
}
else {
printf("Odd Number");
}

return 0;
}
Run Code
#include <stdio.h>
int main() {
int number = 3;
(number % 2 == 0) ? printf("Even Number") : printf("Odd Number");
return 0;
}
We can replace this code with the following code using the ternary operator.

Run Code
Here, both the programs are doing the same task, checking even/odd numbers. However, the
code using the ternary operator looks clean and concise.

In such cases, where there is only one statement inside the if...else block, we can replace it
with a ternary operator.

3
C Arithmetic Operators

An arithmetic operator performs mathematical operations such as addition, subtraction,


multiplication, division etc on numerical values (constants and variables).

Operator Meaning of Operator

+ addition or unary plus

- subtraction or unary minus

* multiplication

/ division

% remainder after division (modulo division)

Example 1: Arithmetic Operators

// Working of arithmetic operators


#include <stdio.h>
int main()
{
int a = 9,b = 4, c;

c = a+b;
printf("a+b = %d \n",c);
c = a-b;
printf("a-b = %d \n",c);
c = a*b;
printf("a*b = %d \n",c);
c = a/b;
printf("a/b = %d \n",c);
c = a%b;
printf("Remainder when a divided by b = %d \n",c);
return 0;
3
}

Run Code
Output

a+b = 13
a-b = 5
a*b = 36
a/b = 2
Remainder when a divided by b=1

The operators +, - and * computes addition, subtraction, and multiplication respectively as


you might have expected.
In normal calculation, 9/4 = 2.25. However, the output is 2 in the program. It is because both
the variables a and b are integers. Hence, the output is also an integer. The compiler neglects
the term after the decimal point and shows answer 2 instead of 2.25. The modulo
operator % computes the remainder. When a=9 is divided by b=4, the remainder is 1.
The % operator can only be used with integers.
Suppose a = 5.0, b = 2.0, c = 5 and d = 2. Then in C programming,

// Either one of the operands is a floating-point number

a/b = 2.5

a/d = 2.5

c/b = 2.5

// Both operands are integers

c/d = 2

C Increment and Decrement Operators:

C programming has two operators increment ++ and decrement -- to change the value of an
operand (constant or variable) by 1.

3
Increment ++ increases the value by 1 whereas decrement -- decreases the value by 1. These
two operators are unary operators, meaning they only operate on a single operand.
Example 2: Increment and Decrement Operators
// Working of increment and decrement operators
#include <stdio.h>
int main()
{
int a = 10, b = 100;
float c = 10.5, d = 100.5;

printf("++a = %d \n", ++a);


printf("--b = %d \n", --b);
printf("++c = %f \n", ++c);
printf("--d = %f \n", --d);

return 0;
}

Run Code
Output

++a = 11
--b = 99
++c = 11.500000
--d = 99.500000

Here, the operators ++ and -- are used as prefixes. These two operators can also be used as
postfixes like a++ and a--.

C Assignment Operators

An assignment operator is used for assigning a value to a variable. The most common
assignment operator is =
Operator Example Same as

= a=b a=b

+= a += b a = a+b

-= a -= b a = a-b

*= a *= b a = a*b

3
Operator Example Same as

/= a /= b a = a/b

%= a %= b a = a%b

Example 3: Assignment Operators


// Working of assignment operators
#include <stdio.h>
int main()
{
int a = 5, c;

c = a; // c is 5
printf("c = %d\n", c);
c += a; // c is 10
printf("c = %d\n", c);
c -= a; // c is 5
printf("c = %d\n", c);
c *= a; // c is 25
printf("c = %d\n", c);
c /= a; // c is 5
printf("c = %d\n", c);
c %= a; // c = 0
printf("c = %d\n", c);

return 0;
}

Run Code
Output

c=5
c = 10
c=5
c = 25
c=5
c=0

C Relational Operators

A relational operator checks the relationship between two operands. If the relation is true, it
returns 1; if the relation is false, it returns value 0.

3
Relational operators are used in decision making and loops.
Operator Meaning of Operator Example

== Equal to 5 == 3 is evaluated to 0

> Greater than 5 > 3 is evaluated to 1

< Less than 5 < 3 is evaluated to 0

!= Not equal to 5 != 3 is evaluated to 1

>= Greater than or equal to 5 >= 3 is evaluated to 1

<= Less than or equal to 5 <= 3 is evaluated to 0

Example 4: Relational Operators

// Working of relational operators


#include <stdio.h>
int main()
{
int a = 5, b = 5, c = 10;

printf("%d == %d is %d \n", a, b, a == b);


printf("%d == %d is %d \n", a, c, a == c);
printf("%d > %d is %d \n", a, b, a > b);
printf("%d > %d is %d \n", a, c, a > c);
printf("%d < %d is %d \n", a, b, a < b);
printf("%d < %d is %d \n", a, c, a < c);
printf("%d != %d is %d \n", a, b, a != b);
printf("%d != %d is %d \n", a, c, a != c);
printf("%d >= %d is %d \n", a, b, a >= b);
printf("%d >= %d is %d \n", a, c, a >= c);
printf("%d <= %d is %d \n", a, b, a <= b);
printf("%d <= %d is %d \n", a, c, a <= c);

return 0;
}
Run Code
Output

5 == 5 is 1
5 == 10 is 0
5 > 5 is 0

3
5 > 10 is 0
5 < 5 is 0
5 < 10 is 1
5 != 5 is 0
5 != 10 is 1
5 >= 5 is 1
5 >= 10 is 0
5 <= 5 is 1
5 <= 10 is 1

C Logical Operators

An expression containing logical operator returns either 0 or 1 depending upon whether


expression results true or false. Logical operators are commonly used in decision making in C
programming.
Operator Meaning Example

Logical AND. True only if If c = 5 and d = 2 then, expression


&&
all operands are true ((c==5) && (d>5)) equals to 0.

Logical OR. True only if If c = 5 and d = 2 then, expression


||
either one operand is true ((c==5) || (d>5)) equals to 1.

Logical NOT. True only if If c = 5 then, expression !(c==5) equals


!
the operand is 0 to 0.

Example 5: Logical Operators

// Working of logical operators


#include <stdio.h>
int main()
{
int a = 5, b = 5, c = 10, result;
result = (a == b) && (c > b);
printf("(a == b) && (c > b) is %d \n", result);

3
result = (a == b) && (c < b);
printf("(a == b) && (c < b) is %d \n", result);
result = (a == b) || (c < b);
printf("(a == b) || (c < b) is %d \n", result);
result = (a != b) || (c < b);
printf("(a != b) || (c < b) is %d \n", result);
result = !(a != b);
printf("!(a != b) is %d \n", result);
result = !(a == b);
printf("!(a == b) is %d \n", result);
return 0;
}
Run Code
Output

(a == b) && (c > b) is 1
(a == b) && (c < b) is 0
(a == b) || (c < b) is 1
(a != b) || (c < b) is 0
!(a != b) is 1
!(a == b) is 0

Explanation of logical operator program


• (a == b) && (c > 5) evaluates to 1 because both operands (a == b) and (c > b) is 1 (true).
• (a == b) && (c < b) evaluates to 0 because operand (c < b) is 0 (false).
• (a == b) || (c < b) evaluates to 1 because (a = b) is 1 (true).
• (a != b) || (c < b) evaluates to 0 because both operand (a != b) and (c < b) are 0 (false).
• !(a != b) evaluates to 1 because operand (a != b) is 0 (false). Hence, !(a != b) is 1 (true).
• !(a == b) evaluates to 0 because (a == b) is 1 (true). Hence, !(a == b) is 0 (false).

C Bitwise Operators

During computation, mathematical operations like: addition, subtraction, multiplication,


division, etc are converted to bit-level which makes processing faster and saves power.

3
Bitwise operators are used in C programming to perform bit-level operations.

Operators Meaning of operators

& Bitwise AND

| Bitwise OR

^ Bitwise exclusive OR

~ Bitwise complement

<< Shift left

>> Shift right

Other Operators

Comma Operator

Comma operators are used to link related expressions together.

For example: int a, c = 5, d;

int a=7,9; //a=7

int a=(7,9); //a=9

The sizeof operator

The sizeof is a unary operator that returns the size of data (constants, variables, array,
structure, etc).
Example 6: sizeof Operator
#include <stdio.h>
int main()
{
int a;
float b;
double c;
char d;
printf("Size of int=%lu bytes\n",sizeof(a));
printf("Size of float=%lu bytes\n",sizeof(b));

3
printf("Size of double=%lu bytes\n",sizeof(c));
printf("Size of char=%lu byte\n",sizeof(d));

return 0;
}

Run Code
Output

Size of int = 4 bytes


Size of float = 4 bytes
Size of double = 8 bytes
Size of char = 1 byte

II. DECISION MAKING

There come situations in real life when we need to make some decisions and based on these
decisions, we decide what should we do next. Similar situations arise in programming also
where we need to make some decisions and based on these decisions we will execute the
next block of code.
For example, in C if x occurs then execute y else execute z. There can also be multiple
conditions like in C if x occurs then execute p, else if condition y occurs execute q, else
execute r. This condition of C else-if is one of the many ways of importing multiple
conditions.

3
Decision-making statements in programming languages decide the direction of the flow of
program execution. Decision-making statements available in C or C++ are:
1. if statement
2. if-else statements
3. nested if statements
4. if-else-if ladder
5. switch statements
6. Jump Statements:
• break
• continue
• goto
• return
1. if statement in C/C++
if statement is the most simple decision-making statement. It is used to decide whether a
certain statement or block of statements will be executed or not i.e if a certain condition is
true then a block of statement is executed otherwise not.
Syntax:
if(condition)
{
// Statements to execute if
// condition is true
}
Here, the condition after evaluation will be either true or false. C if statement accepts
boolean values – if the value is true then it will execute the block of statements below it
otherwise not. If we do not provide the curly braces ‘{‘ and ‘}’ after if(condition) then by
default if statement will consider the first immediately below statement to be inside its
block.
Example:
if(condition)
statement1;
statement2;

// Here if the condition is true, if block


// will consider only statement1 to be inside
// its block.

Flowchart

3
// C program to illustrate If statement
#include <stdio.h>

int main()
{
int i = 10;

if (i > 15) {
printf("10 is greater than 15");
}

printf("I am Not in if");


}

Output:
I am Not in if

3
As the condition present in the if statement is false. So, the block below the if statement is
not executed.
2. if-else in C/C++
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 if 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.
Syntax:
if (condition)
{
// Executes this block if
// condition is true
}
else
{
// Executes this block if
// condition is false
}
Flowchart:

3
// C program to illustrate If statement
#include <stdio.h>

int main()
{
int i = 20;

if (i < 15) {

printf("i is smaller than 15");


}
else {

printf("i is greater than 15");


}
return 0;
}

Output:
i is greater than 15
The block of code following the else statement is executed as the condition present in
the if statement is false.
3. nested-if in C/C++
A nested if in C is an if statement that is the target of another if statement. Nested if
statements mean an if statement inside another if statement. Yes, both C and C++ allow us
to nested if statements within if statements, i.e, we can place an if statement inside another
if statement.
Syntax:
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}

3
Flowchart

Example:

// C program to illustrate nested-if statement


#include <stdio.h>

int main()
{
int i = 10;

if (i == 10) {
// First if statement
if (i < 15)
printf("i is smaller than 15\n");

// Nested - if statement
// Will only be executed if statement above
// is true
if (i < 12)
printf("i is smaller than 12 too\n");
else
printf("i is greater than 15");
}

return 0;
}

Output:
i is smaller than 15
3
i is smaller than 12 too
4. if-else-if ladder in C/C++
Here, a user can decide among multiple options. The C if statements are executed from the
top down. As soon as one of the conditions controlling the if is true, the statement
associated with that if is executed, and the rest of the C else-if ladder is bypassed. If none
of the conditions is true, then the final else statement will be executed.
Syntax:
if (condition)
statement;
else if (condition)
statement;
.
.

else
statement;

3
// C program to illustrate nested-if statement
#include <stdio.h>

int main()
{
int i = 20;

if (i == 10)
printf("i is 10");
else if (i == 15)
printf("i is 15");
else if (i == 20)
printf("i is 20");
else
printf("i is not present");
}

Output:
i is 20
5. Jump Statements in C/C++
These statements are used in C or C++ for the unconditional flow of control throughout the
functions in a program. They support four types of jump statements:
A) break
This loop control statement is used to terminate the loop. As soon as the break statement is
encountered from within a loop, the loop iterations stop there, and control returns from the
loop immediately to the first statement after the loop.
Syntax:
break;
Basically, break statements are used in situations when we are not sure about the actual
number of iterations for the loop or we want to terminate the loop based on some
condition.

3
// C program to illustrate
// to show usage of break
// statement
#include <stdio.h>

void findElement(int arr[], int size, int key)


{
// loop to traverse array and search for key
for (int i = 0; i < size; i++) {
if (arr[i] == key) {
printf("Element found at position: %d",
(i + 1));
break;
}
}
}

int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6 };

// no of elements
int n = 6;

// key to be searched
int key = 3;

// Calling function to find the key


findElement(arr, n, key);

return 0;
}

Output:
Element found at position: 3
B) continue
This loop control statement is just like the break statement.
The continue statement is opposite to that of the break statement, instead of terminating the
loop, it forces to execute the next iteration of the loop.
As the name suggests the continue statement forces the loop to continue or execute the next
iteration. When the continue statement is executed in the loop, the code inside the loop
following the continue statement will be skipped and the next iteration of the loop will
begin.
Syntax:
continue;

3
Example:

// C program to explain the use


// of continue statement
#include <stdio.h>

int main()
{
// loop from 1 to 10
for (int i = 1; i <= 10; i++) {

// If i is equals to 6,
// continue to next iteration
// without printing
if (i == 6)
continue;

else
// otherwise print the value of i
printf("%d ", i);
}

return 0;
}

Output:
1 2 3 4 5 7 8 9 10

3
If you create a variable in if-else in C/C++, it will be local to that if/else block only. You
can use global variables inside the if/else block. If the name of the variable you created in
if/else is as same as any global variable then priority will be given to `local variable`.

#include <stdio.h>

int main()
{

int gfg = 0; // local variable for main


printf("Before if-else block %d\n", gfg);
if (1) {
int gfg = 100; // new local variable of if block
printf("if block %d\n", gfg);
}
printf("After if block %d", gfg);
return 0;
}

Output:
Before if-else block 0
if block 100
After if block 0
C) goto
The goto statement in C/C++ also referred to as the unconditional jump statement can be
used to jump from one point to another within a function.
Syntax:
Syntax1 | Syntax2
----------------------------
goto label; | label:
. | .
. | .
. | .
label: | goto label;
In the above syntax, the first line tells the compiler to go to or jump to the statement
marked as a label. Here, a label is a user-defined identifier that indicates the target
statement. The statement immediately followed after ‘label:’ is the destination statement.
The ‘label:’ can also appear before the ‘goto label;’ statement in the above syntax.

3
Examples:

// C program to print numbers


// from 1 to 10 using goto
// statement
#include <stdio.h>

// function to print numbers from 1 to 10


void printNumbers()
{
int n = 1;
label:
printf("%d ", n);
n++;
if (n <= 10)
goto label;
}

// Driver program to test above function


int main()
{
printNumbers();
return 0;

3
}

Output:
1 2 3 4 5 6 7 8 9 10
D) return
The return in C or C++ returns the flow of the execution to the function from where it is
called. This statement does not mandatorily need any conditional statements. As soon as the
statement is executed, the flow of the program stops immediately and returns the control
from where it was called. The return statement may or may not return anything for a void
function, but for a non-void function, a return value must be returned.
Syntax:
return[expression];
Example:

// C code to illustrate return


// statement
#include <stdio.h>

// non-void return type


// function to calculate sum
int SUM(int a, int b)
{
int s1 = a + b;
return s1;
}

// returns void
// function to print
void Print(int s2)
{
printf("The sum is %d", s2);
return;
}

int main()
{
int num1 = 10;
int num2 = 10;
int sum_of = SUM(num1, num2);
Print(sum_of);
return 0;
}

Output:
The sum is 20

3
III. LOOPS
Loops in programming are used to repeat a block of code until the specified condition is
met. A loop statement allows programmers to execute a statement or group of statements
multiple times without repetition of code.

// C program to illustrate need of loops


#include <stdio.h>

int main()
{
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");
printf( "Hello World\n");

return 0;
}

Output
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
There are mainly two types of loops in C Programming:
1. Entry Controlled loops: In Entry controlled loops the test condition is checked before
entering the main body of the loop. For Loop and While Loop is Entry-controlled
loops.
2. Exit Controlled loops: In Exit controlled loops the test condition is evaluated at the
end of the loop body. The loop body will execute at least once, irrespective of whether
the condition is true or false. do-while Loop is Exit Controlled loop.

3
Loop Type Description

first Initializes, then condition check, then executes the body and at last, the
for loop update is done.

first Initializes, then condition checks, and then executes the body, and
while loop updating can be inside the body.

do-while
loop do-while first executes the body and then the condition check is done.

for Loop
for loop in C programming is a repetition control structure that allows programmers to
write a loop that will be executed a specific number of times. for loop enables programmers
to perform n number of steps together in a single line.
Syntax:
for (initialize expression; test expression; update expression)
{
//
// body of for loop
//
}
Example:
for(int i = 0; i < n; ++i)
{
printf("Body of for loop which will execute till n");
}

3
In for loop, a loop variable is used to control the loop. Firstly we initialize the loop variable
with some value, then check its test condition. If the statement is true then control will
move to the body and the body of for loop will be executed. Steps will be repeated till the
exit condition becomes true. If the test condition will be false then it will stop.
• Initialization Expression: In this expression, we assign a loop variable or loop counter
to some value. for example: int i=1;
• Test Expression: In this expression, test conditions are performed. If the condition
evaluates to true then the loop body will be executed and then an update of the loop
variable is done. If the test expression becomes false then the control will exit from the
loop. for example, i<=9;
• Update Expression: After execution of the loop body loop variable is updated by some
value it could be incremented, decremented, multiplied, or divided by any value.
for loop Equivalent Flow Diagram:

Example:

3
// C program to illustrate for loop
#include <stdio.h>

// Driver code
int main()
{
int i = 0;

for (i = 1; i <= 10; i++)


{
printf( "Hello World\n");
}
return 0;
}

Output
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

While Loop
While loop does not depend upon the number of iterations. In for loop the number of
iterations was previously known to us but in the While loop, the execution is terminated on
the basis of the test condition. If the test condition will become false then it will break from
the while loop else body will be executed.
Syntax:
initialization_expression;

while (test_expression)
{
// body of the while loop

update_expression;

3
}
Flow Diagram for while loop:

// C program to illustrate
// while loop
#include <stdio.h>

// Driver code
int main()
{
// Initialization expression

3
int i = 2;

// Test expression
while(i < 10)
{
// loop body
printf( "Hello World\n");

// update expression
i++;
}

return 0;
}

Output
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

do-while Loop
The do-while loop is similar to a while loop but the only difference lies in the do-while
loop test condition which is tested at the end of the body. In the do-while loop, the loop
body will execute at least once irrespective of the test condition.
Syntax:
initialization_expression;
do
{
// body of do-while loop

update_expression;

} while (test_expression);

3
// C program to illustrate
// do-while loop
#include <stdio.h>

// Driver code
int main()
{
// Initialization expression
int i = 2;

do
{
// loop body

3
printf( "Hello World\n");

// Update expression
i++;

// Test expression
} while (i < 1);

return 0;
}

Output
Hello World
Above program will evaluate (i<1) as false since i = 2. But still, as it is a do-while loop the
body will be executed once.
Loop Control Statements
Loop control statements in C programming are used to change execution from its normal
sequence.

Name Description

the break statement is used to terminate the switch and loop statement. It
break transfers the execution to the statement immediately following the loop or
statement switch.

continue continue statement skips the remainder body and immediately resets its
statement condition before reiterating it.

goto
statement goto statement transfers the control to the labeled statement.

Infinite Loop
An infinite loop is executed when the test expression never becomes false and the body of
the loop is executed repeatedly. A program is stuck in an Infinite loop when the condition is
always true. Mostly this is an error that can be resolved by using Loop Control statements.
Using for loop:

// C program to demonstrate infinite


// loops using for loop
#include <stdio.h>

// Driver code
int main ()
{
int i;

3
// This is an infinite for loop
// as the condition expression
// is blank
for ( ; ; )
{
printf("This loop will run forever.\n");
}

return 0;
}

Output
This loop will run forever.
This loop will run forever.
This loop will run forever.
...
Using While loop:

// C program to demonstrate
// infinite loop using while
// loop
#include <stdio.h>

// Driver code
int main()
{
while (1)
printf("This loop will run forever.\n");
return 0;
}

Output
This loop will run forever.
This loop will run forever.
This loop will run forever.
...
Using the do-while loop:

// C program to demonstrate
// infinite loop using do-while
// loop
#include <stdio.h>

// Driver code
int main()

3
{
do
{
printf("This loop will run forever.\n");
} while (1);

return 0;
}

Output
This loop will run forever.
This loop will run forever.
This loop will run forever.
...

You might also like