Regading interview Question.

S

skishorev

Hi,
Yesterday my friend had taken interview in Microsft.If u know this
Plz answer this


main() // line 1
{
printf("TWO");
} //line4

U don't change from line1 to line4. u will add anything before the
main function only.
write the solution with 10 ways.
We want the ouput is->

One
Two
Three
 
S

Shark

Hi,
Yesterday my friend had taken interview in Microsft.If u know this
Plz answer this


main() // line 1

this is undefined because it is not a standard main() function. It
should return an int at least.
{
printf("TWO");
} //line4

U don't change from line1 to line4. u will add anything before the

if it is c++, just create a static object whose constructor prints the
strings and initialize it before entering main();
 
S

Shark

Hi,
Yesterday my friend had taken interview in Microsft.If u know this
Plz answer this

I wonder why everyone with an email addresses ending in .co.in speaks
in "Plz" and "U". Is this some sort of L33T Indian English??!!!
 
C

Clem.Dickey

I might put these lines at the top:

int main() { printf( "One\nTwo\n ..." ); return 0; }
int this_fn_is_not_\
 
J

Jaspreet

Hi,
Yesterday my friend had taken interview in Microsft.If u know this
Plz answer this


main() // line 1
{
printf("TWO");
} //line4

U don't change from line1 to line4. u will add anything before the
main function only.
write the solution with 10 ways.
We want the ouput is->

One
Two
Three

Kishore, you should have given it a shot yourself instead of asking
this group. Here's the solution (even though I hate spoon-feeding
someone)

#include<iostream>

class A
{
public:
A()
{
std::cout<<"One";
}
~A()
{
std::cout<<"Three";
}
};

A a1;

int main()
{
std::cout<<"Two";
return 0;
}
 
J

Jaspreet

Shark said:
I wonder why everyone with an email addresses ending in .co.in speaks
in "Plz" and "U". Is this some sort of L33T Indian English??!!!

I may not be having a co.in email id but I am from India so lets not go
off-topic and start generalising things about people.

Usage of those words is a result of the SMS lingo and I certainly do
not approve of that. I have pointed that out in a couple of yahoogroups
also.

So, lets be clear its not all Indians but only a negligible minority
that needs to be told about basic rules of posting to a newsgroup.
 
Y

yanamandra

Hi,

Use this.

#define printf(aa) (printf("\nONE\n" "%s" "\nTHREE\n", aa) )

main()
{
printf("TWO");

}

Thanks,
Venu Yanamandra

====
Hi,
Yesterday my friend had taken interview in Microsft.If u know this

Plz answer this


main() // line 1
{
printf("TWO");



} //line4


U don't change from line1 to line4. u will add anything before the
main function only.
write the solution with 10 ways.
We want the ouput is->

One
Two
Three

====
 
S

Shark

Jaspreet said:
I may not be having a co.in email id but I am from India so lets not go
off-topic and start generalising things about people.

Yea lets not go off topic, but you can go **** yourself. What part of
"wonder' didn't you understand?
Usage of those words is a result of the SMS lingo and I certainly do
not approve of that. I have pointed that out in a couple of yahoogroups
also.

Good for you. Don't ever turn to the dark side.
So, lets be clear its not all Indians but only a negligible minority
that needs to be told about basic rules of posting to a newsgroup.

Go **** yourself with Stroustrup's mouse.
 
B

benben

In addition, here are a couple more solutions:

/////////////////////////////////////////
// Solution #1

#include <iostream>

namespace whatever{ // or class or struct
void main(void);
};

int main(void)
{
std::cout << "One\nTwo\nThree\n";
}

void whatever::

main() // line 1
{
printf("TWO");
} //line4



/////////////////////////////////////////
// Solution #2

#include <iostream>

int main(void)
{
std::cout << "One\nTwo\nThree\n";
}

#define main whatever
void

main() // line 1
{
printf("TWO");
} //line4


/////////////////////////////////////////
// Solution #3

#include <cstdlib>
#include <iostream>

class whatever{
public:
whatever(){
std::cout << "One\nTwo\nThree\n";
std::exit(0);
}
};

whatever smash_main_please;

int

main() // line 1
{
printf("TWO");
} //line4




Regards,
Ben
 
J

John Carson

[abusive comments snipped]

Your reaction to a quite reasonable post complaining about stereotyping is
completely over the top and offensive.
 
S

Sunil Varma

John said:
[abusive comments snipped]

Your reaction to a quite reasonable post complaining about stereotyping is
completely over the top and offensive.

Here is one more solution.

/////////////////////
Solution #1
/////////////////////
#include<iostream>
#include<cstdio>
#include<cstdlib>
void fun()
{
printf("Three\n");
}
class base
{
public:
base()
{
atexit(fun);
std::cout<<"One\n";
}
};
base obj;
main()
{
printf("Two\n");
}
 
S

Shark

John said:
[abusive comments snipped]

Your reaction to a quite reasonable post complaining about stereotyping is
completely over the top and offensive.

you got it!
 
K

kalyan

Hi all,
Here is one solution
#define printf("Two") printf("one,Two,three")
main()
{
printf("two");
}
 
R

Ron Natalie

Shark said:
this is undefined because it is not a standard main() function. It
should return an int at least.

It's not even a well-formed definition of any function, C or C++.
Neither language has implicit int in the current incarnations.
 
S

Shark

Default said:
Shark wrote:




Oh, that's a plonk for you.


Brian

For behold, the default knight in shining armor cometh out of his place
to visit the iniquity of the inhabitants of comp.lang.c++ upon them;
and the newsgroup shall disclose its blood, and shall no more cover it
slain.

How good it feels to send the "Oh, that's a plonk for you" over the
internet! I bet your poor soul is a bitch to a supervisor who is
smarter than you.

There are so many email addresses possible that I can come back with a
different alias and ip address each time and you'd again be whoring
with your mustard-seed-sized-knowledge over a post I made because that
is one of the few ways you can feed your ego. You scumbag! Your parents
never thought highly of you. You are dying to lead because you were
always a follower. Shove that keyboard up your cars!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,211
Latest member
NelleWilde

Latest Threads

Top