[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Technical Interview Questions and Answers :: C

    21 / 123

    What is the difference between 'for' and 'while' loops?
    Answer:

    For loop is used when we know how many times

    Please Login First :

    22 / 123

    Which bitwise operator is suitable for checking whether a particular bit is ON or OFF?
    Answer:

    to check if the ith bit is on or off in a number n following  bitwise operation is used.

    flag = n&(1<<i) ;

    if the value of flag is zero then the bit is set otherwise not.
    explanation of above approach is as follows.

    1. lets assume n is 9 so its bitwise operator is 1001 and bitwise representation of 1 is 0001

    2.to check if 4th bit is on we do left shift by 4 on 1 (1<<4) which shift the bits in one to left by 4 unit now the (1<<4)=1000

    3.Finally bitwise and operation is performed so  1001&1000 = 1000 which is not zero so it means that 4th bit of  9 is set

    Please Login First :

    23 / 123

    Which bitwise operator is suitable for turning OFF a particular bit in a number?
    Answer:

    The bitwise operator xor i.e '^' is used to turn off a particular number

    by performing the following operations say we want to turn the ith bit off in a number n

    then n = n^(1<<i)

    Please Login First :

    24 / 123

    What is equivalent of multiplying an unsigned int by 2: left shift of number by 1 or right shift of number by 1?
    Answer:

    multiplying a number by two is equivalent to bitwise left shift of a number by 1 for eg

    1 has a binary representation as 00001 left shift by 1 will make it 00010 which is 2.

    right shift is equivalent to divide a number by 2 .

    left shift is equivalent to multiply a number by 2.

    Please Login First :

    25 / 123

    What is an Enumeration Constant?
    Answer:

    Enumarations are list of integer constants, by default value is zero.

    Please Login First :

    26 / 123

    What is a structure?
    Answer:

    Structure is a function which contains different types of data types and allocation different memory location.

    Please Login First :

    27 / 123

    What are the differences between a structure and a union?
    Answer:

    Structure- It is an user defined data function that allow to store multiple type of data in a single unit.



    It occupies sum of memory of all location.



    Whereas, Union- It is also an user defined data function that allow to store multiple type of data in a single unit.



    But it occupies memory of largest member only. 

    Please Login First :

    28 / 123

    What are the advantages of unions?
    Answer:

    1.memory.

    2.easy to declare.

    Please Login First :

    29 / 123

    How can typedef be to define a type of structure?
    Answer:

    Struct stack

    {

    Please Login First :

    30 / 123

    Write a program that returns 3 numbers from a function using a structure.
    Answer:

    #include<stdio.h>

    struct name{

    int a;

    int b;

    int c;

    };

    struct name func(){

        struct name s1 ;

    s1.a=1;

    s1.b=2;

    s1.c=3;

    return s1;

    }

    int main(){

        struct name val = func();

    }

    Please Login First :