Control Structures in C
Different types of Control Structures in C are: For control, While control and Do control.This note provides an information about control structures in C.
Summary
Different types of Control Structures in C are: For control, While control and Do control.This note provides an information about control structures in C.
Things to Remember
- Different types of Control structures are: For control, While control and Do control.
MCQs
No MCQs found.
Subjective Questions
Q1:
Following table displays the marks obtained by three students Grade IX in three subjects, Full marks of any subject English,Mathematics and Nepali are 100.
(a) Express the information in matrix form.
(b) How many elements are there in the matrix? What is the order of the matrix?
(c) If the matrix is denoted by M, how is it written stating its order.
A | B | C | |
English | 60 | 70 | 68 |
Mathematics | 80 | 92 | 71 |
Nepali | 65 | 62 | 55 |
Type: Long Difficulty: Easy
<p>(a) Writing the given information in the form of matrix,we get,</p>
<p>First Second Third</p>
<p>Column Column Column</p>
<p>\(\begin{bmatrix} 60 & 70 & 68 \\ 80 & 92 & 71 \\ 65 & 62 & 55 \\ \end{bmatrix}\)</p>
<p>here row gives the different students and column gives the marks obtained in each subject.</p>
<p>(b) There are 3 rows and 3 columns in the above matrix. So its order is 3×3.</p>
<p>(c) If the above matrix is represented by M, the,</p>
<p>M=\(\begin{bmatrix} 60 & 70 & 68 \\ 80 & 92 & 71 \\ 65 & 62 & 55 \\ \end{bmatrix}\)</p>
<p>Here order of M is 3×3. This can be written in the matrix notation as</p>
<p>M<sub>3×3</sub> or,\(\begin{bmatrix} 60 & 70 & 68 \\ 80 & 92 & 71 \\ 65 & 62 & 55 \\ \end{bmatrix}\)<sub>3×3</sub></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
Q2:
If B=\(\begin{bmatrix} 20 & 35 & 55 & 70 \\ 25 & 45 & 60 & 75 \\ 30 & 50 & 65 & 80 \\ \end{bmatrix}\)
(a) How many elements are there in B?
(b) What is the order of B? Write down the matrix B in order notation.
Type: Short Difficulty: Easy
Q3:
Is\(\begin{pmatrix} 0 & 0 \\ 0 & 0 \\ 0 & 0 \\ \end{pmatrix}\) equal to \(\begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & 0\\ 0 & 0 & 0 \\ \end{pmatrix}\)? state reason.
Type: Short Difficulty: Easy
Q4:
State that the given matrix is a square or a rectangular matrix.
\(\begin{bmatrix} 1 & 3 \\ 2 & 4 \\ \end{bmatrix}\)
Type: Very_short Difficulty: Easy
<p>\(\begin{bmatrix} 1 & 3 \\ 2 & 4 \\ \end{bmatrix}\). here are two rows and two columns. So, it is a square matrix of order 2.</p>
Q5:
State that the given matrix is a square or a rectangular matrix. [1 2 3 ]
Type: Very_short Difficulty: Easy
Q6:
State that the given matrix is a square or a rectangular matrix.
\(\begin{bmatrix} a & b & c \\ e & f & g \\ \end{bmatrix}\)
Type: Very_short Difficulty: Easy
Q7:
State that the given matrix is a square or a rectangular matrix.
\(\begin{bmatrix} 1 & 3 & 4 \\ 2 & 5 & 6 \\ \end{bmatrix}\)
Type: Very_short Difficulty: Easy
Videos
Introduction to matrices
Modern Maths - Matrices
How to Use Matrices to Solve Linear Equations : Math Fundamentals

Control Structures in C
Branching with if
syntax:
if (condition)
{
statement;
}
else if (condition)
{
statements;
}
..............
else
{
statements
}
Example
/*check if the given number is positive, negative or zero*/
#include
main()
{
int h;
system("cls");
printf("Enter an integer;");
scanf("%d", &h);
if(h>0)
Printf("The number is positive");
else if(h=0)
printf("The number is zero");
else
printf("The number is negative");
For control
syntax:
for(initialize, condition, increment)
{
statement block
}
Example
#include
main()
{
int x;
for(x=1;x<=10;x++)
{
printf("%d\n",x);
}
While control
syntax
while(condition)
{
statement block
}
Example:
#include
main()
{
int x;
x=1;
while(x<=10)
{
printf("%d\n",x);
x++;
}
Do control
syntax
do
{
statement block;
}while(condition)
Example:
#include
main()
{
int x; sum=0;
do
{
printf("enter number");
scanf("%d",&x);
sum=sum+x;
}
while(x!=0);
{
printf("The sum of entered numbers:%d",sum);
}
Lesson
Structured Programming - C Language
Subject
Computer Science
Grade
Grade 10
Recent Notes
No recent notes.
Related Notes
No related notes.