The difference between a "do ...while" loop and a "while {} " loop is that the while loop tests its condition before execution of the contents of the loop begins; the "do" loop tests its condition after it's been executed at least once. As noted above, if the test condition is false as the while loop is entered the block of code is never executed. If the test condition is false as the do while loop is entered the block of code is executed once. Since the condition is tested at the bottom of a do loop, its block of code is always executed at least once.
C++
Topic: Control Flow
What is the difference between while and do while?
Browse random answers:
Write programs using nested loops to produce the following design: * * * * * * * * *
What is Downcasting ?
#include <iostream>using namespace std;int foot (int x, int y) {return((x+y)*3);}int main() {int a = 1;int b = 2;do {cout << foot(b,a);} while ( b < a);return 0;}
Differentiate between the message and method.
What are the decision making statements?
What is the output with using decision making statements method?void main(){ int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n");}
What are conditional operators?
What is the output with using conditional operators method ?void main() {if(~0 == (unsigned int)-1)printf(“You can answer this if you know how values are represented in memory”); }
What is the default scope of if statement?
What is the output?main(){ float me = 1.1; double you = 1.1; if(me==you)printf("I love U");else printf("I hate U");}
Is it necessary if block always nested with else block?
What is the output?int i,j; for(i=0;i<=10;i++) { j+=5; assert(i<5); }
What is the purpose of break and continue statement?
What is the output?main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }
What is the control flow?
What is the purpose of using do-while loop?
At which condition switch statement is used?
What is the subtle error in the following code segment?void fun(int n, int arr[]){int *p=0;int i=0;while(i++<n) p = &arr[i];*p = 0;}
What is the difference between while and do while?
What is the output?main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j);}
What is difference between for loop and while loop ?
hat is the output?main(){while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }
What are Structured programming and C++ flow contro?l
Example of if-else statement?
Example of if-else statement example
Example of else-if construct(else-if ladder)
Example of while loop?
Example of for loop?
Example of break statement?
Example of continue statement
Definition Logical And && ?
Definition Logical Or ||
Definition Logical Not ! ?
Definition Logical Equals == ?
Definition Logical Not Equal != ?
Definition Strictly greater than > ?
Definition Greater than or equal to >=?
Definition Strictly less than < ?
Definition Less than or equal to <= ?
Definition Modulo Division % ?
Definition Incrementer ++ ?
Definition Decrementer -- ?
Definition If statements ?
If Statement Syntax
Definition While statements
Describe Selection – if and switch using C++.?
Explain Loops – While loop, Do-while loop, for loop.
Explain The break statement