Epic Systems Interview Question for Software Engineer / Developers






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

import java.util.Scanner;
   public class NumberQuestion {
   
      public static void main(String[] args){
         Scanner scan = new Scanner(System.in);
         int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, i =0; 
      
         System.out.print("Enter the numbers: ");
      
         while(true){
            i = scan.nextInt();
         
            if(i==0)
               break;
         
            if(i%2 == 0){
               if(i< min)
                  min = i;
            }
            
            else if(i > max)
            {
               max = i;
            }
         }
      
      System.out.print("Min even " + min);
      System.out.print("Max odd " + max);
      }
   
   }

- javacode7 November 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nice and simple!!!

- kalyan359 February 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Does it work for input
1,2,8,9, 0 ?

I guess not !

- Sriram March 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Sriram. I don't understand. Its seems to be working for your input too. Am I missing something?

- varsha March 24, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

keep on reading the numbers one at a time and keep updating the max and min with the condition that max has to be even and min has to be odd...and when user enters 0 print max and min...

- beginner August 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<iostream>

using namespace std;
int main()
{
 int i,min=0,max=0;
 
 int flag1=0,flag2=0;
 
 while((std::cin>>i) && (i!=0))
 {
  //check for even no.
  if(i%2==0)
  {
   if(flag1==0)
    {max=i;
     flag1=1;
    }
   else
   { 
    //check if no is greater than max
    if(i>max)
     max=i;
       
   }  
   
  }else{
  //no is odd
  if(flag2==0)
  {
   min=i;
   flag2=1;
  }
  else{
  //check if no is less than min
  if(i<min)
  min=i;     
  
  }                  
        
  }//end else      
 
 }//end while   
 if(min==0)
 printf("No odd number entered\n");   
 if(max==0)
 printf("No even no entered\n");
 
 printf("\n max=%d,min=%d",max,min);
 
 system("PAUSE");
 return 0;


}

- uber_geek December 02, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
	int input,max=0 ,min=INT_MAX;
	cout<<"Enter stream of integers"<<endl;
	
	while(1)
	{
		cin>>input;
		
		if(input == 0)
			break;
		else
		{			
			if(input>max)
				max=input;
			
			if(input<min)
				min=input;			
		}
	}

	if(max%2==0)
		cout<<"Maximum is "<<max<<endl;
	else
		cout<<"Maximum number is not an even number"<<endl;
	if(min%2==1)
		cout<<"Minimum is "<<min<<endl;
	else
		cout<<"Minimum number is not an odd number"<<endl;

	return 0;
	
}

- Sriram March 04, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is a working code in C++:

#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int n, max, min, flag1, flag2;
    n=1;
    while (n!=0) 
    {
        cin>>n;
        if (n==0)
        {
            break;
        }
        if (n%2==0 && flag1==0)
        {
            max=n;
            flag1=1;
        }
        else if (n%2!=0 && flag2==0)
        {
            min=n;
            flag2=1;
        }
        else if(n%2==0 && n>max)
        {
            max=n;
        }
        else
        {
            min=n;
        }
    }
    cout<<"max in even numbers: "<<max<<endl;
    cout<<"min in odd numbers: "<<min<<endl;
    return 0;
}

- Meraj Ahmed November 10, 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