Uni 1&2 CP
Uni 1&2 CP
Initially, ‘C’ was limited to UNIX OS, but it gradually spread worldwide, and
many compilers were released for cross-platform systems.
Importance of C programming
C programming language offers several advantages over other programming
languages, including:
o Efficiency: C allows for direct memory manipulation and low-level access to
system resources. This results in highly efficient code execution.
o Portability: C code can be easily ported to different platforms without major
modifications, thanks to its wide availability of compilers and libraries.
o Speed: C is known for its fast execution speed, making it suitable for
developing performance-critical applications.
o Control: C gives programmers fine-grained control over memory
management and system resources.
o Compatibility: C code can be easily integrated with code written in other
languages like C++, Java, and Python.
Operating systems: All modern operating systems, such as Windows, Linux,
and macOS, have a significant portion of their codebase written in C.
o Embedded systems: Devices like washing machines, smart TVs, and medical
equipment often run on embedded systems programmed using C.
o Mobile applications: Some parts of mobile applications, including high-
performance tasks and system-level operations, may be implemented in C
for efficiency.
o Gaming consoles: Popular gaming consoles’ core software and engines are
often developed using C.
o Network infrastructure: Routers and networking devices rely on software
written in C to handle complex networking protocols.
Source Character Set (SCS): SCS is used to parse the source code into
internal representation before preprocessing phase. This set includes Basic
Character Set and White-space Characters.
Execution Character Set (ECS): ECS is used to store character string
constants. Other than Basic Character Set, this set contains Control
Characters and Escape Sequences.
Character Set in C
In C, the character set used to represent characters in source code is based on
the ASCII (American Standard Code for Information Interchange) character
set. The ASCII character set includes the following elements:
1. Alphabetic Characters (A-Z, a-z): These represent both uppercase and
lowercase English letters. For example, 'A' to 'Z' and 'a' to 'z'.
2. Digits (0-9): These represent numeric characters. For example, '0' to '9'.
3. Special Characters: These include various special characters used in
programming and text processing. Some common special characters include:
o Arithmetic Operators: +, -, *, /, %
o Relational Operators: <, >, ==, !=, <=, >=
o Logical Operators: &&, ||, !
o Punctuation: ;, :, ,, ., ?, !
o Brackets and Parentheses: (, ), [, ], {, }
o Quotes: ', "
o Backslash: \
o Ampersand: &
o Dollar Sign: $
o Hash or Pound Sign: #
4. Whitespace Characters: These include space (' '), tab ('\t'), newline ('\n'),
carriage return ('\r'), and form feed ('\f'). These characters are used for
formatting and layout in code and text.
5. Control Characters: These include non-printable characters like the escape
character ('\e') and others used for control and formatting, such as '\b'
(backspace), '\t' (tab), and '\n' (newline).
6. Escape Sequences: C allows you to use escape sequences to represent
characters that are difficult to type or invisible. For example, '\n' represents a
newline character, and '\t' represents a tab character.
7. Extended Characters: C also includes characters beyond the ASCII set,
especially for international character encoding. These include characters
with accents, diacritics, and symbols from various languages.
It's important to note that the C standard library, such as <ctype.h>, provides
functions and macros for character handling and manipulation, making it
easier to work with characters and strings in C programs. The character set
serves as the basis for representing and processing text and characters in C
code.
Use of Character Set in C
The character set in C, which is primarily based on the ASCII character set,
is fundamental to working with characters and text in C programming. Here
are several key uses of the character set in C:
1. Declaring and Storing Character Variables: In C, you can declare
character variables to store individual characters. For example:
2. String Handling: C represents strings as arrays of characters. The character
set is used extensively in creating and manipulating strings. For example:
3. Input and Output: The character set is used when reading input and
displaying output using functions like printf and scanf. For example:
4. Comparisons: Characters can be compared using relational operators, and
string comparisons are essential for tasks like sorting and searching within
strings.
5. Conversions: You can convert between characters and other data types,
such as integers and floating-point numbers. This is helpful for character
manipulation and arithmetic.
6. Character Constants: Characters are used as constants, like newline
characters ('\n') or escape sequences, in control statements and text
processing.
7. Loop Control: Characters play a role in loop control, especially in
character-by-character processing. For instance, reading characters in a loop
to process a file character by character.
8. Character Classification: The character set is used for character
classification functions provided by the <ctype.h> library, such
as isalpha, isdigit, and islower, to check character properties.
9. Working with Text Data: C programming often involves text processing,
such as parsing data from files or user input. The character set is essential for
these tasks.
The character set forms the foundation for working with textual data, and it
underlies many of the operations you perform when dealing with characters
and strings in C programming. It allows you to represent, manipulate, and
process text efficiently and effectively in C programs.
Difference between Keyword and Identifier
Keywords: Keywords are specific reserved words in C each of which has a
specific feature associated with it. Almost all of the words which help us use the
functionality of the C language are included in the list of keywords. So you can
imagine that the list of keywords is not going to be a small one! There are a total of
32 keywords in C:
Identifiers: Identifiers are used as the general terminology for naming of
variables, functions and arrays. These are user defined names consisting of
arbitrarily long sequence of letters and digits with either a letter or the
underscore(_) as a first character. Identifier names must differ in spelling and case
from any keywords. You cannot use keywords as identifiers; they are reserved for
special use. Once declared, you can use the identifier in later program statements to
refer to the associated value. A special kind of identifier, called a statement label,
can be used in goto statements. Difference between Keyword and Identifier:
SR.
NO. KEYWORD IDENTIFIER
Keywords are predefined word Identifiers are the values used to define
that gets reserved for working different programming items such as
1 program that have special variables, integers, structures, unions
meaning and cannot get used and others and mostly have an
anywhere else. alphabetic character.
They help to identify a specific They help to locate the name of the
6 property that exists within a entity that gets defined along with a
computer language. keyword.
Data Types in C
Last Updated : 28 Sep, 2023
Each variable in C has an associated data type. It specifies the type of data that the
variable can store like integer, character, floating, double, etc. Each data type requires
different amounts of memory and has some specific operations which can be
performed over it. The data type is a collection of data with values having fixed
values, meaning as well as its characteristics.
The data types in C can be classified as follows:
Types Description
Primitive Data Primitive data types are the most basic data types that are used for
Types representing simple values such as integers, float, characters, etc.
Types Description
User Defined
The user-defined data types are defined by the user himself.
Data Types
The data types that are derived from the primitive or built-in
Derived Types
datatypes are referred to as Derived Data Types.
Different data types also have different ranges up to which they can store numbers.
These ranges may vary from compiler to compiler. Below is a list of ranges along
with the memory requirement and format specifiers on the 32-bit GCC compiler.
Size Format
Data Type (bytes) Range Specifier
unsigned short
2 0 to 65,535 %hu
int
-2,147,483,648 to
int 4 %d
2,147,483,647
-2,147,483,648 to
long int 4 %ld
2,147,483,647
unsigned long 0 to
8 %llu
long int 18,446,744,073,709,551,615
float 4 %f
1.2E-38 to 3.4E+38
double 8 %lf
1.7E-308 to 1.7E+308
Variables in C
A variable in simple terms is a storage place that has some memory allocated to it.
It is used to store some form of data and retrieve it when required. Different types of
variables require different amounts of memory and have some specific set of
operations that can be applied to them.
C Variable Declaration
type variable_name;
type variable1_name, variable2_name, variable3_name;
A variable name can consist of alphabets (both upper and lower case), numbers, and
the underscore ‘_’ character. However, the name must not start with a number.
Constants in C
The constants are those variables or values in the C which cannot be modified once
they are defined in the program.
They have fixed values till the program’s life.
We can only assign value to the constant in the declaration.
There can be any type of constant like integer, float, octal, hexadecimal,
character constants, etc.
The following table lists the differences between the constant and variables in C:
Constant Variables
We can only assign a value to the constant We can assign value to the variable
while defining it. anytime.
Assignment operators are used for assigning value to a variable. The left side
operand of the assignment operator is a variable and right side operand of the
assignment operator is a value. The value on the right side must be of the same data-
type of the variable on the left side otherwise the compiler will raise an error.
Different types of assignment operators are shown below:
1. “=”: This is the simplest assignment operator. This operator is used to assign the
value on the right to the variable on the left. Example:
2. “+=”: This operator is combination of ‘+’ and ‘=’ operators. This operator first
adds the current value of the variable on left to the value on the right and then
assigns the result to the variable on the left. Example:
If initially value stored in a is 5. Then (a += 6) = 11.
3. “-=” This operator is combination of ‘-‘ and ‘=’ operators. This operator first
subtracts the value on the right from the current value of the variable on left and then
assigns the result to the variable on the left. Example:
If initially value stored in a is 8. Then (a -= 6) = 2.
4. “*=” This operator is combination of ‘*’ and ‘=’ operators. This operator first
multiplies the current value of the variable on left to the value on the right and then
assigns the result to the variable on the left. Example:
If initially value stored in a is 5. Then (a *= 6) = 30.
5. “/=” This operator is combination of ‘/’ and ‘=’ operators. This operator first
divides the current value of the variable on left by the value on the right and then
assigns the result to the variable on the left. Example:
Symbolic constants are nothing more than a label or name that is used to represent
some fixed value that never changes throughout the course of a program. For
example, one might define PI as a constant to represent the value 3.14159.
This section consists of the description of the program, the name of the program, and
the creation date and time of the program. It is specified at the start of the program in
the form of comments. Documentation can be represented as:
Anything written as comments will be treated as documentation of the program and
this will not interfere with the given code. Basically, it gives an overview to the reader
of the program.
2. Preprocessor Section
All the header files of the program will be declared in the preprocessor section of the
program. Header files help us to access other’s improved code into our code. A copy
of these multiple files is inserted into our program before the process of compilation.
3. Definition
Preprocessors are the programs that process our source code before the process of
compilation. There are multiple steps which are involved in the writing and execution
of the program. Preprocessor directives start with the ‘#’ symbol. The #define
preprocessor is used to create a constant throughout the program. Whenever this name
is encountered by the compiler, it is replaced by the actual piece of defined code.
4. Global Declaration
The global declaration section contains global variables, function declaration, and
static variables. Variables and functions which are declared in this scope can be used
anywhere in the program.
5. Main() Function
Every C program must have a main function. The main() function of the program is
written in this section. Operations like declaration and execution are performed inside
the curly braces of the main program. The return type of the main() function can be int
as well as void too. void() main tells the compiler that the program will not return any
value. The int main() tells the compiler that the program will return an integer value.
6. Sub Programs
User-defined functions are called in this section of the program. The control of the
program is shifted to the called function whenever they are called from the main or
outside the main() function. These are specified as per the requirements of the
programmer.
1.2. Input/Output (printf and scanf)
C’s printf function prints values to the terminal, and the scanf function reads in
values entered by a user. The printf and scanf functions belong to C’s standard I/O
library, which needs to be explicitly included at the top of any .c file that uses these
functions by using #include <stdio.h>. In this section, we introduce the basics of
using printf and scanf in C programs. The "I/O" section in Chapter 2 discusses C’s
input and output functions in more detail.
1.2.1. printf
C’s printf function is very similar to formatted print in Python, where the caller
specifies a format string to print. The format string often contains formatting
specifiers, such as special characters that will print tabs (\t) or newlines (\n), or
placeholders for values in the output. Placeholders consist of % followed by a type
specifier letter (for example, %d represents a placeholder for an integer value).
1.2.2. scanf
C’s scanf function represents one method for reading in values entered by the user
(via the keyboard) and storing them in program variables. The scanf function can
be a bit picky about the exact format in which the user enters data, which means
that it’s not very robust to badly formed user input. For now, remember that if your
program gets into an infinite loop due to badly formed user input, you can always
press CTRL-C to terminate it.
Reading input is handled differently in Python and C: Python uses
the input function to read in a value as a string, and then the program converts the
string value to an int, whereas C uses scanf to read in an int value and to store it at
the location in memory of an int program
What is a C Operator?
An operator in C can be defined as the symbol that helps us to perform some specific
mathematical, relational, bitwise, conditional, or logical computations on values and
variables. The values and variables used with operators are called operands. So we
can say that the operators are the symbols that perform operations on operands.
For example,
c = a + b;
Here, ‘+’ is the operator known as the addition operator, and ‘a’ and ‘b’ are
operands. The addition operator tells the compiler to add both of the operands ‘a’
and ‘b’.
Types of Operators in C
C language provides a wide range of operators that can be classified into 6 types
based on their functionality:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators
6. Other Operators
1. Arithmetic Operations in C
The arithmetic operators are used to perform arithmetic/mathematical operations on
operands. There are 9 arithmetic operators in C language:
S. No. Symbol Operator Description Syntax
Adds two
+ Plus a+b
1 numeric values.
Subtracts right
– Minus operand from a–b
2 left operand.
Multiply two
* Multiply a*b
3 numeric values.
Divide two
/ Divide a/b
4 numeric values.
Returns the
remainder after
% Modulus diving the left a%b
operand with the
5 right operand.
S. No. Symbol Operator Description Syntax
Used to specify
+ Unary Plus the positive +a
6 values.
Increases the
++ Increment value of the a++
8 operand by 1.
Decreases the
— Decrement value of the a–
9 operand by 1.
2. Relational Operators in C
The relational operators in C are used for the comparison of the two operands. All
these operators are binary operators that return true or false values as the result of
comparison.
These are a total of 6 relational operators in C:
S. No. Symbol Operator Description Syntax
Returns true if
the left operand
< Less than is less than the a<b
right operand.
1 Else false
Returns true if
the left operand
is greater than
> Greater than a>b
the right
operand. Else
2 false
S. No. Symbol Operator Description Syntax
Returns true if
the left operand
is less than or
Less than or
<= equal to the a <= b
equal to
right operand.
Else false
3
Returns true if
the left operand
Greater than is greater than
>= a >= b
or equal to or equal to right
operand. Else
4 false
Returns true if
both the
== Equal to a == b
operands are
5 equal.
Returns true if
both the
!= Not equal to a != b
operands are
6 NOT equal.
Returns true if
both the
&& Logical AND a && b
operands are
1 true.
both or any of
the operand is
true.
Returns true if
! Logical NOT the operand is !a
3 false.
4. Bitwise Operators in C
The Bitwise operators are used to perform bit-level operations on the operands. The
operators are first converted to bit-level and then the calculation is performed on the
operands. Mathematical operations such as addition, subtraction, multiplication, etc.
can be performed at the bit level for faster processing.
There are 6 bitwise operators in C:
S. No. Symbol Operator Description Syntax
Performs bit-by-
bit AND
& Bitwise AND operation and a&b
returns the
1 result.
Performs bit-by-
bit OR operation
| Bitwise OR a|b
and returns the
2 result.
Performs bit-by-
bit XOR
^ Bitwise XOR operation and a^b
returns the
3 result.
Shifts the
number in
binary form by
Bitwise
<< one place in the a << b
Leftshift
operation and
returns the
5 result.
Shifts the
number in
binary form by
Bitwise
>> one place in the a >> b
Rightshilft
operation and
returns the
6 result.
5. Assignment Operators in C
Assignment operators are used to assign value to a variable. The left side operand of
the assignment operator is a variable and the right side operand of the assignment
operator is a value. The value on the right side must be of the same data type as the
variable on the left side otherwise the compiler will raise an error.
The assignment operators can be combined with some other operators in C to
provide multiple operations using single operator. These operators are called
compound operators.
In C, there are 11 assignment operators :
6. Other Operators
Conditional Operator ( ? : )
The conditional operator is the only ternary operator in C++.
Here, Expression1 is the condition to be evaluated. If the
condition(Expression1) is True then we will execute and return the result
of Expression2 otherwise if the condition(Expression1) is false then we
will execute and return the result of Expression3.
We may replace the use of if..else statements with conditional operators.
in
Unary operators are the operators that perform operations on a single operand to
produce a new value.
Types of unary operators
Types of unary operators are mentioned below:
1. Unary minus ( – )
2. Increment ( ++ )
3. Decrement ( — )
4. NOT ( ! )
5. Addressof operator ( & )
6. sizeof()
1. Unary Minus
The minus operator ( – ) changes the sign of its argument. A positive number
becomes negative, and a negative number becomes positive.
is different from the subtraction operator, as subtraction requires two operands.
Below is the implementation of the unary minus (-) operator:
2. Increment
The increment operator ( ++ ) is used to increment the value of the variable by 1.
The increment can be done in two ways:
2.1 prefix increment
In this method, the operator precedes the operand (e.g., ++a). The value of the
operand will be altered before it is used.
3. Decrement
The decrement operator ( — ) is used to decrement the value of the variable by 1.
The decrement can be done in two ways:
3.1 prefix decrement
In this method, the operator precedes the operand (e.g., – -a). The value of the operand
will be altered before it is used.
4. NOT ( ! )
The logical NOT operator ( ! ) is used to reverse the logical state of its operand. If a
condition is true, then the Logical NOT operator will make it false.
5. Addressof operator ( & )
The addressof operator ( & ) gives an address of a variable. It is used to return the
memory address of a variable. These addresses returned by the address-of operator are
known as pointers because they “point” to the variable in memory.
C
Arithmetic Expressions
An arithmetic expression is an expression that consists of operands and arithmetic
operators. An arithmetic expression computes a value of type int, float or double.
When an expression contains only integral operands, then it is known as pure integer
expression when it contains only real operands, it is known as pure real expression, and
when it contains both integral and real operands, it is known as mixed mode expression.
Relational Expressions
A relational expression is an expression used to compare two operands.
Logical Expressions
o A logical expression is an expression that computes either a zero or non-zero value.
o It is a complex test condition to take a decision.
a 4. Assignment Expressions: Assignment expressions are used to assign values to variables. They use the
assignment operator (=) to store a value on the left side into a variable on the right
Operator precedence dictates the order in which operators are evaluated within an expression. The precedence
of different operators is specified by a set of rules in the C programming language. For instance, division and
multiplication take precedence over addition and subtraction. Additionally, parentheses can be used to compel
Associativity of Operators
When an expression contains two operators of equal priority the tie between
them is settled using the associativity of the operators. Associativity can be of
two types—Left to Right or Right to Left. Left to Right associativity means that
the left operand must be unambiguous. Unambiguous in what sense? It must not
be involved in evaluation of any other sub-expression. Similarly, in case of
Right to Left associativity the right operand must be unambiguous. Let us
understand this with an example.
1. Parentheses ()
2. Unary Operators (++ and --)
3. Multiplication, Division, and Modulus (*, /, and %)
4. Addition and Subtraction (+ and -)
The higher the position of an operation in this hierarchy, the greater precedence it
has. Arithmetic operators of equal precedence are evaluated from left to right.
The conditional statements (also known as decision control structures) such as if, if
else, switch, etc. are used for decision-making purposes in C programs.
They are also known as Decision-Making Statements and are used to evaluate one or
more conditions and make the decision whether to execute a set of statements or not.
These decision-making statements in programming languages decide the direction of
the flow of program execution.
Need of Conditional Statements
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.
Types of Conditional Statements in C
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
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. The if-else statement consists of two blocks, one for false
expression and one for true expression.
Syntax of if else in C
if (condition)
{
// Executes this block if
// condition is true
}
else
{
// Executes this block if
// condition is false
}
Flowchart of if-else Statement
The block of code following the else statement is executed as the condition present
in the if statement is false.
3. Nested if-else in 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, C allow us to
nested if statements within if statements, i.e, we can place an if statement inside
another if statement.
Syntax of Nested if-else
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
else
{
// Executes when condition2 is false
}
Flowchart of Nested if-else
4. if-else-if Ladder in C
The if else if statements are used when the user has to 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. if-else-if ladder is similar to the switch
statement.
Syntax of if-else-if Ladder
if (condition)
statement;
else if (condition)
statement;
.
.
else
statement;
Flowchart of if-else-if Ladder
Flow Diagram of if-else-if
5. switch Statement in C
The switch case statement is an alternative to the if else if ladder that can be used to
execute the conditional code based on the value of the variable specified in the
switch statement. The switch block consists of cases to be executed based on the
value of the switch variable.
Syntax of switch
switch (expression) {
case value1:
statements;
case value2:
statements;
....
C) goto
The goto statement in C also referred to as the unconditional jump statement can be
used to jump from one point to another within a function.
Syntax of goto
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.
Flowchart of switch in C
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
do-while first executes the body and then the condition check is done.
loop
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");
}
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:
C
// 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;
}
Flow Diagram for while loop:
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.
Types of Jump Statements in C
There are 4 types of jump statements in C:
1. break
2. continue
3. goto
4. return
1. break in C
The break statement exits or terminates the loop or switch statement based on a
certain condition, without executing the remaining code.
Uses of break in C
The break statement is used in C for the following purposes:
1. To come out of the loop.
2. To come out from the nested loops.
3. To come out of the switch case.
4.
will break the inner loop without affecting the execution of the outer loop.
Example of break Statement
The statements inside the loop are executed sequentially. When the break statement
is encountered within the loop and the condition for the break statement becomes
true, the program flow breaks out of the loop, regardless of any remaining iterations.
Explanation:
Loop Execution Starts and goes normally till i = 5.
When i = 6, the condition for the break statement becomes true and the
program control immediately exits the loop.
The control continues with the remaining statements outside the loop.
switch statement to terminate the switch statement after the matching case is
executed.
2. Continue in C
The continue statement in C is used to skip the remaining code after the continue
statement within a loop and jump to the next iteration of the loop. When the
continue statement is encountered, the loop control immediately jumps to the next
iteration, by skipping the lines of code written after it within the loop body.
Syntax of continue in C
Flowchart of continue Statement
A nested loop means a loop statement inside another loop statement. That is why
nested loops are also called “loop inside loops“. We can define any number of loops
inside another loop.
1. Nested for Loop
Nested for loop refers to any type of loop that is defined inside a ‘for’ loop. Below is
the equivalent flow diagram for nested ‘for’ loops:
A nested loop means a loop statement inside another loop statement. That is why
nested loops are also called “loop inside loops“. We can define any number of loops
inside another loop.
1. Nested for Loop
Nested for loop refers to any type of loop that is defined inside a ‘for’ loop. Below is
the equivalent flow diagram for nested ‘for’ loops:
Nested for loop in C