Recent questions tagged loop

5 5 votes
2 2 answers
304
304 views
What is the output of the following code?#include <stdio.h int main() { int a[5] = {2, 4, 1, 3, 5}; int i, sum = 0; for (i = 0; i < 5; i++) { if (a[i] % 2 == 0) sum = sum...
12 12 votes
1 1 answer
355
355 views
What is the output of the following code?#include <stdio.h int main() { int i, j, sum = 0; for (i = 1; i <= 4; i++) { for (j = 1; j <= 4; j++) { if (j == i) continue; if ...
12 12 votes
2 2 answers
428
428 views
What is the output of the following code?#include <stdio.h int main() { int i, j, count = 0; for (i = 1; i <= 3; i++) { for (j = 1; j <= i; j++) { count = count + j; } } ...
0 0 votes
2 2 answers
373
373 views
In the following code the operator $\textsf{%}$ denotes the remainder after integer division. That is: for positive integers $\textsf{a,b}$ the value $\textsf{a % b}$ is ...
0 0 votes
1 1 answer
167
167 views
In the following pseudocode segment, A denotes an array and len(A) denotes the number of elements in that array. The array is indexed from $1$ to len(A). Write down the a...
2 2 votes
1 1 answer
810
810 views
#include <stdio.h int main () { int i, k; int a [8] = {33,34,35,36,37,40,50,38}; for(i = 0; i < 3; i++) { a[i] = a[i] + 1; i=i+1; } i=i-1; for (k = 7; k 4; k ) { int i =...
0 0 votes
1 answers 1 answer
1.0k
1.0k views
How many times is the comparison $i >= n$ performed in the following program?int i = 200 n = 80; main() { while (i >= n) { i = i - 2 n = n + 1 } }
1 1 vote
2 answers 2 answers
971
971 views
In the picture below:Can anyone explain to me why ‘while’ loop starting from 2 but in the case of ‘for’ loop it is starting from 1 (although i++ is available for both in ...
0 0 votes
1 1 answer
418
418 views
In what sequence the initialization, testing and execution of body is done while using do-while loop?CommentingExecution of the bodyInitialisationTesting the conditionCho...
0 0 votes
1 1 answer
718
718 views
Assume a relation ‘R’ having 200 records. These records are stored in blocks having block factor as 20. Consider another relation ‘S’ having 120 records and all these rec...
0 0 votes
1 1 answer
1.0k
1.0k views
can anyone explain how the for loop works here..?
0 0 votes
0 0 answers
616
616 views
𝑙𝑜𝑜𝑝:1. 𝐴𝐷𝐷𝐼 𝑅2, 𝑅2, #12. 𝐿𝐷 𝑅4, 0(𝑅3)3. 𝐿𝐷 𝑅5, 4(𝑅3)4. 𝐴𝐷𝐷 𝑅6, 𝑅4, 𝑅55. 𝑀𝑈𝐿 𝑅4, 𝑅6, 𝑅76. 𝑆𝑈𝐵𝐼 𝑅3, 𝑅3, #87. 𝐵𝑁𝐸𝑍 𝑅2, 𝑙𝑜𝑜𝑝8. 𝐴𝐷𝐷 𝑅11, 𝑅12, 𝑅13Question: Assume a 5-stage pi...
0 0 votes
0 0 answers
972
972 views
In a programmed I/O technique, the processor is stuckin a wait loop doing status checking of an I/O device.To increase efficiency, the I/O software could be writ-ten so t...
0 0 votes
2 answers 2 answers
1.1k
1.1k views
What will be the output printed for find(4)? void find(int x) { static int i = 10, y = 0; y = y + i; for(i; i>0; i = i - 10) { if(x! = 0) find(x – 1); else printf(“%d”, y...