Part 1:
1. A counter controlled iteration structure works on satisfying some condition. The
counter variable is initialized with some value and a condition is checked on every
iteration and only if it satisfies it executes the loop body and when condition is not
satisfies, it exits the loop. The counter variable increments or decrements on each
iteration which controls the loop. Below is an example code:
int i;
for (i = 1; i <= 10; i++)
{
printf("%d ", i);
}
2. A for() statement is a loop statements which iterates over a piece of code on the
basis of a specific condition and keep iterating as long as the condition satisfies.
While switch statement is used to write conditional statement which executes
specific codes on the basis of various condition, it never iterates like a loop. A real
world example would be like when we need to calculate the average grades of
students by adding their individual scores, we will use a loop to iterate over a list of
scores. And when we need to find out the letter grade of students, we will use a
switch statement which will help us in finding the letter grade on the basis of scores.
3. A function is a set of instructions written to do a specific tasks. We would use a
function in C to avoid code duplicity. For example, if there is a set of statements
which is being used at many places in program, we may put it inside a function and
call it where it needs. Three items that are needed to implement a function are
function name, function parameters which are the values passed to the function, and
return type which specifies what type of data is being returned.