Epic Systems Interview Question
Software Engineer / DevelopersLittle faster program (Since bitwise operations are faster)
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,max1=-1,max2=-1;
while(scanf("%d",&n)>0)
{
if(n == 0)break;
if(n&1)
{
if(n > max1)max1=n;
}
else
{
if(n>max2)max2=n;
}
}
printf("Max odd = %d\nMax even = %d\n",max1,max2);
return 0;
}
#include<stdio.h>
main()
{ int i ,j ;
int n,s=0;
char a[50],b[50],c[50];
char tmp;
printf("Enter the number\n");
i=0;
scanf("%c",&a[0]);
while(a[i]!='0')
{ i++;
scanf("%c",&a[i]);
}
a[i]='\0';
printf("the input is %s\n",a);
sscanf(a,"%d",&n);
if(n%2==0)
{ printf("the largest even no is %d\n",n);
s++;
}
else
printf("The largest odd no is %d\n",n);
if(s==1)
{ while(n%2!=1)
n=n/10;
printf("The largest odd no is %d\n",n);
}
else
{ while(n%2!=0)
n=n/10;
printf("The largest even no is %d\n",n);
}
}
#include<stdio.h>
- MN May 13, 2010#include<conio.h>
int main()
{
int n;
int max1=0,max2=1;
printf("\nplease enter the numbers");
scanf("%d",&n);
while(n!=0)
{
if(n%2==0)
if(n>max1) max1=n;
if(n%2!=0)
if(n>max2) max2=n;
scanf("%d",&n);
}
printf("Max even is %d and max odd is %d",max1,max2);
return 0;
}