Samsung Interview Question for Software Engineer / Developers


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
3
of 5 vote

infinite loop

- kedarsdixit April 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

for(test();test();test()) should be

- aka April 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

yes you are right for(test();test();test())

But what will be the output ?

- pirate April 13, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

for(;3;) this will be infinite loop as basically it gets translated to
for(;true;)

- aka April 13, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

222222....infinite time

- mithunaunli10 July 08, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

for(test();test();test()) should be

- aka April 13, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

01. It'll give compile time error given main "}" is not present.
02. If you add "}" at the end then:
(a) it'll give warning for "i" is declared but not used.
(b)for(test();test();test()) {/* do somethibng */}
translates into
for(3;3;3)
i.e. for(initial condition; FALSE; LoopExpression)
it'll print 2 once, as in C++ 0 is TRUE and >0 is FALSE.

- vj April 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It is printing 2 infinite times. I used VC++ 6.0. source file type was C++. May be u need to check ur ans. again

- mkumar9009 April 21, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It will be infinite loop as in C++ 0 is FALSE and >0< is TRUE.

- cyberphoenix May 15, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

it give compile time error because retutn type of test() is not mentioned.

- xxxxx April 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

"it give compile time error because retutn type of test() is not mentioned."
-> it will not give compile time error because if you not mentioned a return type ,in C it will take a int as default return type.

- Pavankumar April 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

It will print 2 infinite time.
But why do you declare i unnecessarily it will take space ( program optimization) mention return type of test() in definition.

- Avi April 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
test()//by default return type is int
{
return 3;
}
void main()
{
int i=2;
for(test();test();test())
{
printf("2");
}
getch();
return 0;
}

OUTPUT: Infinite Loop (if last ; is not there in for loop if it is there then compile time error)

- Bobby May 07, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Compile time error will come because return type of test is not mention and for loop consist of only two semicolon.

- Saumya Gupta July 30, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you are not considering syntax errors then it will be a infinite loop other otherwise commpile time error.

- Ayush September 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this is compile time error. The error is for(test();test();test();). here if we get The output to this prgm. we change The for(test=i ,i= 2, i ++). I think this is The solution. It is not confirm.

- kanmani July 02, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

no need to mention return type of test() because defaultly it takes integer

- balu November 30, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If compiled in C then infinite time 2 will be printed.

- Rohan January 22, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

it give compile time error because retutn type of test() is not mentioned.

- xxxxx April 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

It will get compile time error because the return type of test() is not mentioned. If correct this, even then it will not compile due the for loop line. The expression in the for loop must be a boolean value. Moreover, a for loop statement cannot have more than 2 semicolons.

- dee April 15, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More