Homework Programmation in c Language

Слайд 2

1. How many loops are there in C ++? List them.

1. How many loops are there in C ++? List them. There

There are 3 types of loops for, do, while

Слайд 3

When is the cycle used for?

The cycle used for the

When is the cycle used for? The cycle used for the initialization the main program.
initialization the main program.

Слайд 4

Write syntax loop for

for (declare and initialise counter; test value

Write syntax loop for for (declare and initialise counter; test value of
of counter; change value of counter) {   statement(s) }

Слайд 5

What is iteration?

Iteration is the process where a set of

What is iteration? Iteration is the process where a set of instructions
instructions or statements is executed repeatedly for a specified number of time or until a condition is met. These statements also alter the control flow of the program and thus can also be classified as control statements in C Programming Language.

Слайд 6

What is a cycle counter?

A program counter is a register

What is a cycle counter? A program counter is a register in
in a computer processor that contains the address (location) of the instruction being executed at the current time. As each instruction gets fetched, the program counter increases its stored value by 1.

Слайд 7

What will the program output as a result?

8 1                                                                                                                                  
9 0 

What will the program output as a result? 8 1 9 0

Слайд 8

7. What is the difference between cycles while and do while

7. What is the difference between cycles while and do while and
and a cycle for

A) The while loop. General form
The while loop is called a loop with a precondition
b) The general form of the cycle operator ‘do … while’
The ‘do … while’ loop should be used in cases where the iteration should be done at least once. Unlike ‘for’ and ‘while’ loops, in the ‘do … while’ loop, the condition is checked when the loop exits (and not when entering the loop). The ‘do … while’ loop is also called a cycle with a postcondition.
c) In C++, the ‘for’ loop can have a very wide implementation and application. The ‘for’ loop is also called a cycle with a parameter.

Слайд 9

8. Write syntax loop while

The syntax of a while loop

8. Write syntax loop while The syntax of a while loop in
in C programming language is −
while(condition) { statement(s); }

Слайд 10

9. What is iteration?
Iteration is the process where a

9. What is iteration? Iteration is the process where a set of
set of instructions or statements is executed repeatedly for a specified number of time or until a condition is met. These statements also alter the control flow of the program and thus can also be classified as control statements in C Programming Language.

Слайд 11

10. What will the program output as a result?

10. What will the program output as a result?

Слайд 12

11. What is the difference between cycle while and do while

11. What is the difference between cycle while and do while While

While loop is executed only when given condition is true. Whereas, do-while loop is executed for first time irrespective of the condition. After executing while loop for first time, then condition is checked.

Слайд 13

Write syntax loop do while

The syntax of a do...while loop

Write syntax loop do while The syntax of a do...while loop in
in C programming language is −
do { statement(s); } while( condition );