EMC Interview Question for Software Engineer in Tests


Team: RSA
Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
4
of 4 vote

can recursion be used?if yes

PrintNum(1);

PrintNum(int n){
 printf("%d",n);
 if(n==500)
  return
 PrintNum(n+1);
}

- Anonymous June 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 vote

/* use of goto staements  */
#include<stdio.h>


main()

{
int i=1;
  A: 
  if(i<=500)
  {
  printf("%d\t",i);
  i++;
  goto A;
    }
 else 
 exit(0);
    
}

- Anonymous June 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

nicely explained............

- ketan June 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use TMP - Template Meta Programming, to get the required functionality.

#include <iostream>
template<int N>
struct NumberGeneration{
	static void out(std::ostream& os)
	{
		NumberGeneration<N-1>::out(os);
		os << N << std::endl;
	}
};
template<>
struct NumberGeneration<1>{
	static void out(std::ostream& os)
	{
		os << 1 << std::endl;
	}
};
int main(){
	NumberGeneration<100>::out(std::cout);
}

- ashot madatyan June 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
int i=1;
void main()
{
if(i<=500)
{
printf("%d /n",i);
++i;
main();
}
}

- Akshay Thapliyal July 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static int count = 0;
	
	public static void printNums(){
		System.out.print(" "+(count++)+" ");
		if(count<=500){
			printNums();
		}

}

- Nitesh December 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Without loops, print 500 consecutive numbers? Recursion NOT allowed.

The answer is so simple :)

printf("1,2,3,4,5...498,499,500");

If recursion is allowed, The function can be:

void serial(int i) {
    if(i > 0) { print("%d,", i); serial(i-1); }
}

serial(500);

It'll print 500 numbers in serial order (but in reverse)

- devsathish August 12, 2014 | 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