1hey man i think you do not get the sum... the lengh of the nuimerator and denominator will always be two since you you are starting at 10 and ending at 99 always. Next if the numerator and denminator are equal crosswise then u have to check the remaining two characters when divided is equal to the actual answer i.e.
Quote:
|
let the fraction be ab/cd then if a=d or b=c then we check that if b/c or a/d respectively whichever is not cut off or whichever is left is equal to ab/cd or not...
|
I have written the program today and want to share it my frenz here.. This program was a code segment to be written in a qualifying paper of an IT company's recruitment exam which wanted to check logical skills of the ppl sitting in the exam.
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
int i,j;
double x,y;
for(i=10;i<=99;i++)
{
for(j=10;j<=99;j++)
{
y=i*1.0/j;
if((i/10)==(j%10))
{
x=(i%10)*1.0/(j/10);
if(x/y==1.0)
{
printf(" %d",i);
printf("---");
printf("%d",j);
printf("\t");
}
}
else if((i%10)==(j/10))
{
x=(i/10)*1.0/(j%10);
if(x/y==1.0)
{
printf(" %d",i);
printf("---");
printf("%d",j);
printf("\t");
}
}
}
}
}