# KPK Board 10th Class Computer Ch 5 Loop Structure Short Questions Answers

We are providing all Students from 5th class to master level all exams preparation in free of cost. Now we have another milestone achieved, providing all School level students to the point and exam-oriented preparation question answers for all science and arts students.

After Online tests for all subjects now it’s time to prepare the next level for KPK board students to prepare their short question section here. We have a complete collection of all classes subject wise and chapter wise thousands questions with the right answer for easy understanding.

We provided 10th class Computer short questions answers on this page of all KPK boards. Students of KPK boards can prepare the Computer subject for annual examinations.

In this List we have included all KPK boards and both Arts and Science students. These Boards students can prepare their exam easily with these short question answer section

Malakand Board 10th classes short questions Answer

Mardan Board 10th classes short questions Answer

Peshawar Board 10th classes short questions Answer

Swat Board 10th classes short questions Answer

Dera Ismail Khan Board 10th classes short questions Answer

Kohat Board 10th classes short questions Answer

Bannu Board 10th classes short questions Answer

All above mention KPK Boards students prepare their annual and classes test from these online test and Short question answer series. In coming days we have many other plans to provide all kinds of other preparation on our Gotest website.

How to Prepare KPK Board Classes Short Question Answer at Gotest

• Just Open the desired Class and subject which you want to prepare.
• You have Green bars which are Questions of that subject Chapter. Just click on Bar, it slides down and you can get the right answer to those questions.
Explain different types of looping structures with examples.

Ans. Looping Structure: A structure that repeats a statement or set / group of statements is known as looping structure. It is also known as repetitive structure.
TYPES OF LOOPING STRUCTURE
In C /C ++ language, three types of looping structure are available. These are explained below
1. For loop:
The ‘for’ loop is used in that case where the number of loop iterations are known in advance i.e. to print the tables, counting etc.
The syntax is
For (Initialization ; Condition ; Increment / Decrement)
Body of the loop;
‘Initialization’ means the starting of loop. It defines the starting value of loop.
‘Condition’ is a relational expression. It specifies the test/ check condition on the basis of which the loop will execute. The looping statement will execute till the given condition is satisfied.
‘Increment / decrement’ is set to increase the number of looping iterations.
‘Body of loop’ consists of all those C – statements that will be repeated again till the end of loop. In case of single statement, the block is not defined but in case of more than one looping statement the block is defined inside the braces. { and}.
Example:
For (x=1 ; x<5 ; x ++)
Printf(“%d \ t”, x);
Explanation:
Here “x = 1” is looping initializations. “x<10” is a check condition and “x++” is looping increment. The “body of loop” consists of two statements that will repeat till the end of loop. When the condition ‘x<10’ because False, the loop will stop execution.
The output will come as
1 OK
2 OK
3 OK
4 OK
In order to print the number’s in descending order (i.e. 4, 3, 2, 1), the for loop will be used as
For (x = 4; x >0 ; x –)
Printf(“%d\t”, x);
Flowchart of “for” loop
While loop:

It is another common type of looping structure available in C/C++ language. It can perform all the same actions as performed by ‘ for’ loop however it is useful in that situations where the number of loop iterations are not known in advance. For example the users are asked to enter/ input the positive numbers and in case of negative number the loop will stop executing. Now it is not confirmed that how much positive number will be inputted.
Syntax:
Initialization;
While(condition)
Body of loop;
Increment / Decrement;
‘While’ is a C – reserved word. ‘Condition’ is a Boolean expression that will return True / False. If it is satisfied the body of loop will execute otherwise it will stop.
Example:
Following programming code will the message ‘Pakistan’ 10 times.
Int = 1;
While(x <= 10)
Printf(Pakistan\n”);
X = x +1 ;
The “while” loop is ideally used when the number of iterations are not known in advance. Let us write a C – program that will ask the users to enter / input the +ve number and in case of –ve number the loop will stop execution. The program will count the positive number and display them.
#include<stdio.h>
#includ<conio.h>
Void main
Int x, c;
Clrscr ()
X = 0;
C = 0;
Printf(“Enter Positive Number, Negative number will end the program\n” );
While(x>=0)
Printf(Enter new Number \n”)
Scanf(“%d”,&x);
C = c + 1;
Printf(“you enetered %d positive number \n”,c)
Printf(“The loop runs for %d times”,c);
SAMPLE OUTPUT
Enter Positive number, Negative number will end the program
2
Enter new Number
12
Enter new Number
-6
You entered 2 positive Number
The loop runs for 2 times.
do while loop:

It is third looping structure available in C language. It works with rather different syntax. In this loop, the text/ check condition comes after the loop iteration is processed. It is post- test loop. The body of loop will must run at least once
Syntax:
Initialization;
Do
Body of the loop;
Increment / Decrement;
While (condition);
‘do’ and ‘while’ are C-reserved words. The do-while loop starts with the ‘do’ statement.
Example:
The following programming code will print the message ‘Pakistan’ 10 times.
Int = 1;
Do
{
Printf(“Pakistan\n”);
}
While(x<=10)
FLOWCHART for ‘do while’ loop.
You Can Learn and Gain more Knowledge through our Online Quiz and Testing system Just Search your desired Preparation subject at Gotest.
error: