search
Log In

Recent questions tagged loop

3 votes
3 answers
1
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
asked Apr 29, 2019 in Programming manikgupta123 525 views
0 votes
0 answers
2
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) ?
asked Jan 19, 2019 in Programming newdreamz a1-z0 93 views
2 votes
2 answers
3
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); } (A) False, it checks whether a given number is ... , it checks whether a given number is odd or not (D) True, it checks whether a given number is perfect square. Any one can explain output of above program?
asked Dec 14, 2018 in Programming Gangani_Son 879 views
0 votes
0 answers
4
#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?
asked Sep 27, 2018 in Programming aditi19 30 views
2 votes
0 answers
5
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
asked Dec 17, 2017 in Programming amIndian 369 views
0 votes
1 answer
6
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
asked Dec 12, 2017 in Programming Sahil1994 112 views
3 votes
1 answer
7
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?
asked Oct 17, 2017 in Programming Abhi Girin 543 views
0 votes
3 answers
8
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
asked Oct 27, 2016 in Programming Sankaranarayanan P.N 131 views
1 vote
0 answers
9
#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 = res2 ^ a[i]; 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 ?
asked Oct 19, 2016 in Programming dd 454 views
1 vote
2 answers
10
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.
asked Sep 6, 2016 in Programming makhdoom ghaya 311 views
1 vote
1 answer
11
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 according to my knowledge. Even ... get incremented 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
asked Aug 8, 2016 in Programming pC 899 views
3 votes
1 answer
12
0 votes
3 answers
13
int main(){ int a; a = 1; while(a-- >= 1) while(a-- >= 0); printf("%d", a); }
asked Apr 4, 2016 in Programming Registered user 7 184 views
3 votes
2 answers
14
Consider the following function. Assume that the array contains list of all the numbers from 1 to k &ndash;1. What is the return value of function BSR? Sum of all numbers Repeated number in the list Average of all the numbers None of these ----------------------------- ... value & substracting last from it which is also (k-1*k) /2 . So it will always return 0. Q 37 Made Easy FLT 6-Practice Test 14
asked Dec 1, 2015 in Programming Akash Kanase 221 views
To see more, click for the full list of questions or popular tags.
...