What will be the output-
for(i=1;i<=3;i++)
{
printf("%d",i);
continue;
i++;
}

Answers were Sorted based on User's Feedback



What will be the output- for(i=1;i<=3;i++) { printf("%d",i); ..

Answer / gourab

the o/p will be 123

bcz after printing 1 for d first time then continue will
take to the for statement.thus i will take value 3.and i++
after d continue statement will never get executed,but it
will not give an error.

Is This Answer Correct ?    32 Yes 2 No

What will be the output- for(i=1;i<=3;i++) { printf("%d",i); ..

Answer / chetan

This will not result in a Compiler-error, because "Unreachable-code" is a warning in C, not a compilation error.

The output will be:
123

Is This Answer Correct ?    6 Yes 2 No

What will be the output- for(i=1;i<=3;i++) { printf("%d",i); ..

Answer / harshit

This will result in compiler error as the code i++; inside
the for loop is not reachable.

If continue statement is enclosed within an if construct
then only the program will compile.

Is This Answer Correct ?    14 Yes 13 No

What will be the output- for(i=1;i<=3;i++) { printf("%d",i); ..

Answer / mehtaashish

It will results in a compile time error, stating that
unreachable code for the second increment statement(i++) after
continue statement.

Is This Answer Correct ?    11 Yes 10 No

What will be the output- for(i=1;i<=3;i++) { printf("%d",i); ..

Answer / sakshi arora

The output will be : 123
bcozZ unreachable code is a warning in c , not a compilation error..

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C++ Code Interview Questions

. Write a program using two-dimensional arrays that computes the sum of data in tows and the sum of data in columns of the 3x3 (three by three) array variable n[3][3].

2 Answers   IBM,


Given a table of the form: Product Sold on A 1/1/1980 B 1/1/1980 C 1/1/1980 A 1/1/1980 B 1/1/1980 C 2/1/1980 A 2/1/1980 There are 30 products and 10,000 records of such type. Also the month period during which sales happened is given to u. Write the program to display the result as: Product Month No. of copies A January 12 A February 15 A March 27 B January 54 B February 15 B March 10 C January 37

0 Answers   Nagarro,


Complexity T(n) What is the time complexity T(n) of the following portions of code? For simplicity, you may assume that n is a power of 2. That is, n = 2k for some positive integer k. a) ? for (i = 1; i <= n; i++) { j = n; cout << i << ? ? j << ? ? << endl; } b) ? for (i = 0; i <= n; i += 2) { j = n; cout << i << ? ? j << ? ? << endl; } c) ? for (i = n; i >= 1; i = i/2) { j = n; cout << i << ? ? j << ? ? << endl; } d) for (i = 1; i <= n; i++) { j = n; while (j >= 0) { cout << i << ? ? j << ? ? << endl; j = j - 2; } }

0 Answers   Qatar University,


Show by induction that 2n > n2, for all n > 4.

2 Answers   Karvy, Qatar University,


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

0 Answers  






write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150

0 Answers  


write a program that accepts a number and outputs its equivalent in words. take note that the maximum input is 3000

1 Answers   Alvin,


how to write a program that opens a file and display in reverse order?

0 Answers   SMC,


Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and with complexity T(n) is at most about (1.5)n comparisons.

10 Answers   ABC, College School Exams Tests, ITC Infotech, Kyambogo University, Qatar University,


A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect

0 Answers  


using repetition structure. Write a c program that will accept five numbers. The program should count and output the total count of even numbers and total count of add numbers.

2 Answers  


What output does the following code generate? Why? What output does it generate if you make A::Foo() a pure virtual function? class A { A() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; class B : public A { B() { this->Foo(); } virtual void Foo() { cout << "A::Foo()" << endl; } }; int main(int, char**) { A objectA; B objectB; return 0; }

0 Answers  


Categories