Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Recent questions tagged loop
0
votes
1
answer
1
Made Easy Test Series 2024
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 } }
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 } }
Ray Tomlinson
425
views
Ray Tomlinson
asked
Aug 9, 2023
Algorithms
algorithms
algorithm-design
loop-invariants
loop
time-complexity
+
–
1
votes
2
answers
2
Loops (while and for)
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 Program 1 and Program 2) and also in the case of while' loop the outputs are ... ' loop the outputs are same although in Program 2 it is post increment (i++) and in Program 4 it is pre increment (++i).
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 ...
Gopal6854
557
views
Gopal6854
asked
Jul 29, 2023
Programming in C
programming
loop
+
–
0
votes
1
answer
3
TestBook TestSeries Finding number of records under join of 2 tables
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 records are stored in 30 blocks. These two tables have to be joined ... the total number of block access required to join R and S ? A. 2430 B. 6010 C. 6120 D. 1230
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 t...
Sahil_Lather
337
views
Sahil_Lather
asked
Jan 29, 2023
Databases
databases
algorithms
loop
testbook-test-series
+
–
0
votes
1
answer
4
Unacacdemy AIMT 2
can anyone explain how the for loop works here..?
can anyone explain how the for loop works here..?
TusharKumar
510
views
TusharKumar
asked
Dec 22, 2022
Programming in C
programming-in-c
output
loop
+
–
0
votes
0
answers
5
University Assignment
𝑙𝑜𝑜𝑝: 1. 𝐴𝐷𝐷𝐼 𝑅2, 𝑅2, #1 2. 𝐿𝐷 𝑅4, 0(𝑅3) 3. 𝐿𝐷 𝑅5, 4(𝑅3) 4. 𝐴𝐷𝐷 𝑅6, 𝑅4, 𝑅5 5. 𝑀𝑈𝐿 𝑅4, 𝑅6, 𝑅7 6. 𝑆𝑈𝐵𝐼 𝑅3, 𝑅3, #8 7. 𝐵𝑁𝐸𝑍 𝑅2, 𝑙𝑜𝑜𝑝 8. 𝐴𝐷𝐷 𝑅11, 𝑅12, 𝑅13 Question: Assume a 5-stage pipeline (IF ID EX MEM WB) ... All stages take 1 cycle. Again, the loop takes one iteration to complete. Which dependencies from part (a) cause stalls? How many cycles does the loop take to execute?
𝑙𝑜𝑜𝑝:1. 𝐴𝐷𝐷𝐼 𝑅2, 𝑅2, #12. 𝐿𝐷 𝑅4, 0(𝑅3)3. 𝐿𝐷 𝑅5, 4(𝑅3)4. 𝐴𝐷𝐷 𝑅6, 𝑅4, 𝑅55. 𝑀𝑈𝐿 𝑅4, 𝑅6...
lalitver10
414
views
lalitver10
asked
Nov 14, 2022
CO and Architecture
pipelining
computer-architecture
loop
+
–
0
votes
0
answers
6
Trishna's GATE CSE
In a programmed I/O technique, the processor is stuck in a wait loop doing status checking of an I/O device. To increase efficiency, the I/O software could be writ- ten so that the processor periodically checks the status of the device. If the device is not ready, ... The printing rate is slowed to 5 CPS (C) The printing rate is at 10 CPS only (D) The printing rate is at 20 CPS
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...
eskaykaushik
481
views
eskaykaushik
asked
Oct 18, 2022
Computer Networks
operating-system
input-output
loop
+
–
0
votes
2
answers
7
made easy gate cs question bank
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); } }
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...
rohitkaushal1
474
views
rohitkaushal1
asked
Sep 22, 2022
Programming in C
algorithms
programming-in-c
loop
+
–
3
votes
2
answers
8
GO Classes Test Series 2024 | Programming | Test 3 | Question: 23
What will be the output of the following lines of code? int i = 0; int j = 0; char *s = "ceded"; while (s[i] != '\0') { j = j + s[i] - 'b'; i = i + 1; } printf("%d %d\n", i, j); $5\; 11$ $4\; 16$ $5\; 16$ $4 \;11$
What will be the output of the following lines of code?int i = 0; int j = 0; char *s = "ceded"; while (s[i] != '\0') { j = j + s[i] - 'b'; i = i + 1; } printf("%d %d\n", ...
GO Classes
269
views
GO Classes
asked
Apr 30, 2022
Programming in C
goclasses2024-programming-3-weekly-quiz
goclasses
programming
programming-in-c
loop
output
2-marks
+
–
6
votes
4
answers
9
GO Classes 2023 | Weekly Quiz 4 | Question: 10
int find(int n) { int i, j, k, a = 1; for (i = 1; i <= n; i++) for (j = 1; j <= i; j++) for (k = 1; k <= j; k++) a = a + 1; return a; } What will be the value of find$(10)$?
int find(int n) { int i, j, k, a = 1; for (i = 1; i <= n; i++) for (j = 1; j <= i; j++) for (k = 1; k <= j; k++) a = a + 1; return a; }What will be the value of find$(10)...
GO Classes
695
views
GO Classes
asked
Mar 26, 2022
Programming in C
goclasses_wq4
numerical-answers
programming
programming-in-c
loop
goclasses
2-marks
+
–
3
votes
3
answers
10
PGEE 2019
for(int i=0; i<=100;i++) { if (i % 3 == 0) printf("Great); if(i%5 == 0) printf("India"); } Count the number of times GreatIndia is printed. 6 20 33 none of these
for(int i=0; i<=100;i++) { if (i % 3 == 0) printf("Great); if(i%5 == 0) printf("India"); }Count the number of times GreatIndia is printed.62033none of these
manikgupta123
1.8k
views
manikgupta123
asked
Apr 29, 2019
Programming in C
iiith-pgee
loop
counting
programming
+
–
1
votes
0
answers
11
me test series
i have 1 doubt regarding the initialization of highlighted portion.Will the value of ’k’ change at each iteration or it will remain same (whatever value assigned to it during for loop initialization) ?
i have 1 doubt regarding the initialization of highlighted portion.Will the value of ’k’ change at each iteration or it will remain same (whatever value assigned to i...
newdreamz a1-z0
337
views
newdreamz a1-z0
asked
Jan 18, 2019
Programming in C
programming-in-c
for
loop
+
–
4
votes
2
answers
12
What is the return value of following function for 484? What does it to in general?
What is the return value of following function for 484? What does it to in general? bool fun(int n) { int sum = 0; for (int odd = 1; n > sum; odd = odd+2) sum = sum + odd; return (n == sum ... is odd or not (D) True, it checks whether a given number is perfect square. Any one can explain output of above program?
What is the return value of following function for 484? What does it to in general?bool fun(int n){ int sum = 0; for (int odd = 1; n sum; odd = odd+2) sum = ...
Gangani_Son
2.0k
views
Gangani_Son
asked
Dec 14, 2018
Programming in C
programming-in-c
functions
programming
loop
+
–
0
votes
0
answers
13
Doubt
#include <stdio.h> int main() { int i = 0; do { printf("Hello "); i = i++; } while (i < 5); return 0; } why this prints Hello infinitely? shouldn't it print Hello 5 times?
#include <stdio.h>int main(){ int i = 0; do { printf("Hello "); i = i++; } while (i < 5); return 0;}why this prints Hello infinitely?shoul...
aditi19
191
views
aditi19
asked
Sep 27, 2018
Programming in C
loop
+
–
4
votes
1
answer
14
C programming
Consider the following program fragment: int d = 0; int i,j,k; for(i=1; i<31; ++i) for(j=1; j<31; ++j) for(k=1; k<31; ++k) if(((i+j+k)%3) == 0) d=d+1; printf("%d",d); The number of additions performed by the above program fragment is? a. 27,000 b. 27,000 x 3 c. 27,000 x 3 + 9,000 d. 9,930 + 2,700 x 3
Consider the following program fragment:int d = 0; int i,j,k; for(i=1; i<31; ++i) for(j=1; j<31; ++j) for(k=1; k<31; ++k) if(((i+j+k)%3) == 0) d=d+1; printf("%d",d);The n...
amIndian
1.7k
views
amIndian
asked
Dec 17, 2017
Programming in C
programming-in-c
output
loop
+
–
1
votes
1
answer
15
#self doubt
What will be the output of following program:- Size of int is 4 bytes #incude<stdio.h> int main() { int a; for(a=1;a<=2147483647;a++) printf("%d\n",a); return 0; } a) will it print till its limit 2147483647 b) it will go to indefinate loop c) compile time error
What will be the output of following program:-Size of int is 4 bytes#incude<stdio.h>int main(){ int a; for(a=1;a<=2147483647;a++) printf("%d\n",a); r...
Sahil1994
550
views
Sahil1994
asked
Dec 11, 2017
Programming in C
programming-in-c
loop
+
–
4
votes
1
answer
16
GATEFORUM
for(i=0;i<=n;i++){ for(j=0;j<=i2;j++){ for(k=0;k<=$\frac{n}{2}$;k++){ x=y+z; }}} How many times the x=y+z statement will execute?
for(i=0;i<=n;i++){ for(j=0;j<=i2;j++){ for(k=0;k<=$\frac{n}{2}$;k++){ x=y+z;}}}How many times the x=y+z statement will execute?
Abhi Girin
1.0k
views
Abhi Girin
asked
Oct 16, 2017
Programming in C
programming-in-c
time-complexity
for
loop
asymptotic-notation
normal
+
–
15
votes
1
answer
17
ISRO2017-63
What does the following program do when the input is unsigned 16 bit integer? #include<stdio.h> main(){ unsigned int num; int i; scanf("%u", &num); for(i=0;i<16;i++){ printf("%d", (num<<i&1<<15)?1:0); } } It prints all even bits from num It prints all odd bits from num It prints binary equivalent of num None of above
What does the following program do when the input is unsigned 16 bit integer?#include<stdio.h main(){ unsigned int num; int i; scanf("%u", &num); for(i=0;i<16;i++){ print...
sh!va
8.4k
views
sh!va
asked
May 7, 2017
Programming in C
isro2017
programming-in-c
loop
+
–
8
votes
5
answers
18
ISRO2017-62
What will be the output of the following C code? #include <stdio.h> main() { int i; for(i=0;i<5;i++) { int i=10; printf("%d" , i); i++; } return 0; } 10 11 12 13 14 10 10 10 10 10 0 1 2 3 4 Compilation error
What will be the output of the following C code?#include <stdio.h main() { int i; for(i=0;i<5;i++) { int i=10; printf("%d" , i); i++; } return 0; }10 11 12 13 1410 10 10 ...
sh!va
8.6k
views
sh!va
asked
May 7, 2017
Programming in C
isro2017
programming-in-c
loop
output
+
–
0
votes
3
answers
19
Kerala PSC AP Exam
What is the output of this C code? #include<stdio.h> int main() { do printf("Inside while loop"); while(0); printf("After while loop"); } A) Infinite loop B) Compilation error C) After while loop D) Inside while loop After while loop
What is the output of this C code?#include<stdio.h int main() { do printf("Inside while loop"); while(0); printf("After while loop"); }A) Infinite loopB) Compilation erro...
Sankaranarayanan P.N
551
views
Sankaranarayanan P.N
asked
Oct 27, 2016
Programming in C
programming-in-c
loop
+
–
1
votes
0
answers
20
C programming
#include <stdio.h> int main() { int a[10]; int i=0,j=0; int res1=0,res2=0; int res[10]={0}; for(i=0;i<10;i++) { a[i] = i+1; for(j=0;j<10;j++) { if(i!=j) res[j] = res[j] ^ a[i]; } } for(i=0;i<10;i++) { if(i&1) res2 = ... ; else res1 = res1 ^ a[i]; } int sum=0; for(i=0;i<10;i++) sum += res1^res2^res[i]; printf("%d\n",sum); } Output of the above program ?
#include <stdio.h int main() { int a[10]; int i=0,j=0; int res1=0,res2=0; int res[10]={0}; for(i=0;i<10;i++) { a[i] = i+1; for(j=0;j<10;j++) { if(i!=j) res[j] = res[j] ^ ...
dd
759
views
dd
asked
Oct 19, 2016
Programming in C
programming-in-c
output
loop
+
–
1
votes
2
answers
21
UGC NET CSE | December 2010 | Part 2 | Question: 14
Which one of the following sentences is true ? The body of a while loop is executed at least once. The body of a do … while loop is executed at least once. The body of a do … while loop is executed zero or more times. A for loop can never be used in place of a while loop.
Which one of the following sentences is true ?The body of a while loop is executed at least once.The body of a do … while loop is executed at least once.The body of a d...
makhdoom ghaya
3.7k
views
makhdoom ghaya
asked
Sep 5, 2016
Programming in C
ugcnetcse-dec2010-paper2
programming
loop
+
–
1
votes
1
answer
22
If statement C programming
int i=0,j=0; if(i&&j++)printf (print I, j) printf(print I, j) output : is 0,0 My Question is.. ' if' statement is executed and failed as I and j have values 0,0 then why j is not incremented output has to be 0,1 ... after if loop. Why it is not happening? Ps: I'm not able to follow proper style in coding as I'm typing from mobile. Please excuse
int i=0,j=0;if(i&&j++)printf (print I, j)printf(print I, j)output : is 0,0My Question is.. ' if' statement is executed and failed as I and j have values 0,0then why j is...
pC
1.7k
views
pC
asked
Aug 8, 2016
Programming in C
programming-in-c
output
loop
+
–
Page:
1
2
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register