TCS latest placement papers 2012 with solutions

Company:TCS

Location:Noida

Submitted by:Neha

 

 

 

Technical:

 

 

1) class Sample

{

public:

        int *ptr;

        Sample(int i)

        {

        ptr = new int(i);

        }

        ~Sample()

        {

        delete ptr;

        }

        void PrintVal()

        {

        cout << “The value is ” << *ptr;

        }

};

void SomeFunc(Sample x)

{

cout << “Say i am in someFunc ” << endl;

}

int main()

{

Sample s1= 10;

SomeFunc(s1);

s1.PrintVal();

}

Answer:

Say i am in someFunc

Null pointer assignment(Run-time error)

 

2) class base

        {

        public:

                void baseFun(){ cout<<”from base”<<endl;}

        };

 class deri:public base

        {

        public:

                void baseFun(){ cout<< “from derived”<<endl;}

        };

void SomeFunc(base *baseObj)

{

        baseObj->baseFun();

}

int main()

{

base baseObject;

SomeFunc(&baseObject);

deri deriObject;

SomeFunc(&deriObject);

}

Answer:

                from base

                from base

3) What would be the output of the following program.

                        #include<stdio.h>

                        main()

                        {

                            char str[5]=”fast”;

                            static char *ptr_to_array = str;

                            printf(“%s”,ptr_to_array);

                        }

   (a) Compilation will only give a warning but will proceed to execute & will display “fast”

   (b) display “fast” on screen                  (c) will give a compilation error                     (d) none of the above

4).What would be the output of the following program.

                        main()

                        {

                            int num,*p;

                            num=5;

                            p=&num;

                            printf(“%d”,*p);

                        }

           (a) 6                       (b) 5                           (c) junk value                       (d) compilation error

5) What would be the output of the following program.

                        main()

                        {

                            int a[3]={2,3,4};

                            char *p;

                            p=a;

                            p=(char *)((int *)p+1);

                            printf(“%d”,p);

                        }

           (a) 2                           (b) 0                           (c) junk value                           (d) 3

6).What would be the output of the following program.

                        main()

                        {

                            int i=10;

                            fn(i);

                            printf(“%d”,i);

                        }

                        fn(int i)

                        {

                            return ++i;

                        }

           (a) 10                           (b) 11                           (c) 12                           (d) Compilation error

7). What will be the value of i & j after the loop isexecuted?<BR>                         for(i=0,j=0;i<5,j<25;i++,j++)

          (a) i=4,j= 24                  (b) i=24,j= 24                  (c) i=25,j= 25                  (d) i=5,j=25

Aptitude reasoning:

 

 

 

1)A Flight takes off at 2 A.M from northeast direction and travels for 11 hours to reach the destination which is in north west direction. Given the latitude and longitude of source and destination. Find the local time of destination when the flight reaches there? 7 AM or 1.00 PM

2) My flight takes of at 2am from a place at 18N 10E and landed 10 Hrs later at a place with coordinates 36N70W. What is the local time when my plane landed.

a) 6:00 am b) 6:40am c)7:40 d)7:00 e)8:00 (Hint : Every 1 deg longitude is equal to 4 minutes . If west to east add time else subtract time) Ans 8:00

3)A moves 3 kms east from his starting point . He then travels 5 kms north. From that point he moves 8 kms to the east.How far is A from his starting point?Ans. 13 kms

4)Aeroplane is flying at a particular angle and latitude,after some time another latitude is given..(8 hrs later), u r asked to find the local time of the place.

5)AN AEROPLANE STARTS FROM A (SOME LATITUDE IS GIVEN ACCORDING TO PLACE)AT 2 AM LOCAL TIME TO B(SOME LATITUDE). TRAVELLLING TIME IS 10 HOURS. WHAT IS THE LOCAL TIME OF B WHEN IT REACHES B

6)A plane moves from 9°N40°E to 9°N40°W. If the plane starts at 10 am and takes 8 hours to reach the destination, find the local arrival time.

This entry was posted in Companies, Tech-Mahindra. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>