Professional Documents
Culture Documents
Student Name
Student University ID
Date
● Initialize arrays (initializer list and using loops) and printing arrays
After studying the above concepts, answer the following questions, which are intended to
prepare you for the coming lab.
Experiment 4.1:
Experiment Objectives
✔ Understand the structure of the while loop
What does the following code segment display? Try each of these inputs: 12,
9, 3.
printf(“\nEnter a positive integer> “);
scanf(“%d”, &num);
while (num > 0) {
if(num % 2 == 0)
printf(“%d\t”, num);
num--;
} printf(“\n”);
Experiment 4.2:
Experiment Objectives
✔ Understand the structure of the for loop compared with while loop
product = 1;
i = 0;
while (i < n) {
scanf(“%d”, &a);
if (a != i)
product *= a;
++i;
}
Experiment 4.3:
Experiment Objectives
✔ Declare and initialize arrays
2. Declare and array and initialize it with the statement: “I Like C Programming”
3. Declare an array of size five and initialize it with zeros.