The intention of the following program fragment is to display the positive integers from 1 through n, but it doesn't work. Correct the while statement so the fragment achieves the desired effect.

```
i = 1;
while (i <= n)
printf("%d ", n);
i = i + 1;
printf("\n");
```


```
while (i <= n) {
printf("%d ", i);
i = i + 1;
}
```

Computer Science & Information Technology

You might also like to view...

Assume a linked list is made of nodes from a Node struct, which has an info data member and a next data member. Suppose a pointer called ptr points to a node in the middle of the linked list. To move ptr to the next node, we should use the code:

A. ptr = next; B. next->ptr; C. ptr->next; D. ptr = ptr->next;

Computer Science & Information Technology

Rewrite the domain relational calculus queries that followed Q0 in Section 6.7 in the style of the abbreviated notation of Q0A, where the objective is to minimize the number of domain variables by writing constants in place of variables wherever possible.

What will be an ideal response?

Computer Science & Information Technology

What is a file whose format is patented or copyright protected and controlled by a single company?

a. Open source b. Proprietary file c. PostScript

Computer Science & Information Technology

Within a selection statement, an expression that evaluates to 0 or less is considered as false, while any positive is considered as true.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology