HTC Global Services Interview Question
Software DevelopersCountry: India
Interview Type: Written Test
double n = 4 , total = 0;
int j = 10;
for (int i = 0; i<j ; i++)
{
double Num = i + 1;
if(Num > n)
{
total = (i + 1) / (n - 1);
cout << (i+1) << "/" << n - 1 << " + ";
}
else if(Num == n)
{
//No Need to do anything.
}
else
{
total = i + 1 / n;
cout << (i+1) << "/" << n << " + ";
}
}
cout << endl << "Total is " << total << endl;
double n = 5 , total = 0;
int j = 10;
for (int i = 0; i<j ; i++)
{
double Num = i + 1;
if(Num > n)
{
total = (i + 1) / (n - 1);
cout << (i+1) << "/" << n - 1 << " + ";
}
else if(Num == n)
{
//No Need to do anything.
}
else
{
total = i + 1 / n;
cout << (i+1) << "/" << n << " + ";
}
}
cout << endl << "Total is " << total << endl;
- NoIdea December 08, 2016