Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Compare and contrast the while and for repetition statements Write four differen

ID: 3802918 • Letter: C

Question

Compare and contrast the while and for repetition statements Write four different C language statements that each add 1 to integer variable x. Explain the purpose of a function parameter. What is the difference between a parameter and an argument? What are the advantages of using a symbolic constant rather than a literal constant? What are the first and last element of int someArrayl25]; What is an expression? What are the differences between the function prototype and the function definition? Is it possible to create a loop that never ends? Give an example.

Explanation / Answer

1."for" loop is generally used when we know the number of loops that are to be executed previously

syntax: for(initialization;condition;increment or decrement){

//statements to be executed

}

"while" loop is executed where we donot know how many times the loop to be executed.

syntax: while(condition){

   //statements to be executed

};

2. (i) x=x+1

   (ii) x+=1

   (iii)x++

(iv)++x

3.Function paramenters are values that are given to the function so that it can utilize those values for any purpose. An argument is the actual value that is passed to the function as input when it is called. Whereas parameters are variables that are declared in function declaration to represent those arguments.

4. Symbolic constants are generally evaluated by the pre processor which means they are written as literal values. Whereas a literal constant is a value that is directly typed into the program where values cannot be changed

Example: int k=42;

42 is directly assigned to k which cannot be changed.

In symbolic constants values can be changed.

5. First element is called as arrInt[size]

   Last element is called as arrInt[size-1]

where size is the array of integers. In this question size is 25.

6.Expression is a combination of symbols that represents a value.

Ex: x+42 is an expression

7.Function prototype is a function declaration that declares the type of its arguments.

Example: int i(int b)

Function definition defines the function itself. It also provides declarartion where it contains the type of parameters and prototype

Example: int i(int b){return b;}

8. Loop that never ends indicates an "INFINITE LOOP" OR "ENDLESS LOOP" is a sequence of instructions in a program that loops without end due to the loop having no termination condition or one that causes the loop to start again

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote