Regading interview Question.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • skishorev@yahoo.co.in

    #1

    Regading interview Question.

    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

  • Shark

    #2
    Re: Regading interview Question.


    skisho...@yahoo .co.in wrote:[color=blue]
    > Hi,
    > Yesterday my friend had taken interview in Microsft.If u know this
    > Plz answer this
    >
    >
    > main() // line 1[/color]

    this is undefined because it is not a standard main() function. It
    should return an int at least.
    [color=blue]
    > {
    > printf("TWO");
    > } //line4
    >
    > U don't change from line1 to line4. u will add anything before the[/color]

    if it is c++, just create a static object whose constructor prints the
    strings and initialize it before entering main();
    [color=blue]
    > main function only.
    > write the solution with 10 ways.
    > We want the ouput is->
    >
    > One
    > Two
    > Three[/color]

    Comment

    • skishorev@yahoo.co.in

      #3
      Re: Regading interview Question.

      Yes It is in c++ only.

      Comment

      • Shark

        #4
        Re: Regading interview Question.

        skishorev@yahoo .co.in wrote:[color=blue]
        > Hi,
        > Yesterday my friend had taken interview in Microsft.If u know this
        > Plz answer this[/color]

        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??!!!

        Comment

        • Clem.Dickey@gmail.com

          #5
          Re: Regading interview Question.

          I might put these lines at the top:

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

          Comment

          • Jaspreet

            #6
            Re: Regading interview Question.

            skishorev@yahoo .co.in wrote:[color=blue]
            > 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[/color]

            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<iostre am>

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

            A a1;

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

            Comment

            • Jaspreet

              #7
              Re: Regading interview Question.

              Shark wrote:[color=blue]
              > skishorev@yahoo .co.in wrote:[color=green]
              > > Hi,
              > > Yesterday my friend had taken interview in Microsft.If u know this
              > > Plz answer this[/color]
              >
              > 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??!!![/color]

              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.

              Comment

              • yanamandra

                #8
                Re: Regading interview Question.


                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

                ====

                Comment

                • Shark

                  #9
                  Re: Regading interview Question.

                  Jaspreet wrote:[color=blue]
                  > Shark wrote:[color=green]
                  > > skishorev@yahoo .co.in wrote:[color=darkred]
                  > > > Hi,
                  > > > Yesterday my friend had taken interview in Microsft.If u know this
                  > > > Plz answer this[/color]
                  > >
                  > > 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??!!![/color]
                  >
                  > 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.[/color]

                  Yea lets not go off topic, but you can go fuck yourself. What part of
                  "wonder' didn't you understand?
                  [color=blue]
                  >
                  > 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.[/color]

                  Good for you. Don't ever turn to the dark side.
                  [color=blue]
                  >
                  > 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.[/color]

                  Go fuck yourself with Stroustrup's mouse.

                  Comment

                  • benben

                    #10
                    Re: Regading interview Question.

                    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\nThre e\n";
                    }

                    void whatever::

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



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

                    #include <iostream>

                    int main(void)
                    {
                    std::cout << "One\nTwo\nThre e\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\nThre e\n";
                    std::exit(0);
                    }
                    };

                    whatever smash_main_plea se;

                    int

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




                    Regards,
                    Ben

                    Comment

                    • John Carson

                      #11
                      Re: Regading interview Question.

                      "Shark" <cpp_shark@yaho o.com> wrote in message
                      news:1138175581 .797163.43040@g 49g2000cwa.goog legroups.com

                      [abusive comments snipped]

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

                      --
                      John Carson


                      Comment

                      • Sunil Varma

                        #12
                        Re: Regading interview Question.


                        John Carson wrote:[color=blue]
                        > "Shark" <cpp_shark@yaho o.com> wrote in message
                        > news:1138175581 .797163.43040@g 49g2000cwa.goog legroups.com
                        >
                        > [abusive comments snipped]
                        >
                        > Your reaction to a quite reasonable post complaining about stereotyping is
                        > completely over the top and offensive.
                        >
                        > --
                        > John Carson[/color]

                        Here is one more solution.

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

                        Comment

                        • Shark

                          #13
                          Re: Regading interview Question.

                          John Carson wrote:[color=blue]
                          > "Shark" <cpp_shark@yaho o.com> wrote in message
                          > news:1138175581 .797163.43040@g 49g2000cwa.goog legroups.com
                          >
                          > [abusive comments snipped]
                          >
                          > Your reaction to a quite reasonable post complaining about stereotyping is
                          > completely over the top and offensive.[/color]

                          you got it!
                          [color=blue]
                          >
                          > --
                          > John Carson[/color]

                          Comment

                          • kalyan

                            #14
                            Re: Regading interview Question.

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

                            Clem.Dickey@gma il.com wrote:[color=blue]
                            > I might put these lines at the top:
                            >
                            > int main() { printf( "One\nTwo\n ..." ); return 0; }
                            > int this_fn_is_not_ \[/color]

                            Comment

                            • Ian Collins

                              #15
                              Re: Regading interview Question.

                              Shark wrote:[color=blue]
                              > Jaspreet wrote:
                              >[color=green]
                              >>Shark wrote:
                              >>[color=darkred]
                              >>>skishorev@ya hoo.co.in wrote:
                              >>>
                              >>>>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??!!![/color]
                              >>
                              >>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.[/color]
                              >
                              >
                              > Yea lets not go off topic, but you can go[/color]

                              Pubs close early did they?

                              Go some place else to post your abuse.

                              --
                              Ian Collins.

                              Comment

                              Working...