[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.

C Interview Questions and Answers

    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 :


Frequently asked C Interview Questions and Answers at Freshers and experience level. All Question are based on the real time experience of previous candidates. You can search and filter the question set by company name from the tag cloud.

Q4I Collection of C Programming Interview Questions and Answers with Explanations asked in campus/off-campus interviews, walk-in interview and various IT companies Interview at Freshers & Experienced level. Multiply your selection chance by practicing the C Interview Question from basic to Standard, or by going through Company specific pattern of question asked from C Programming.

So, next time, when you prepare for a company's interview, please check your knowledge against these C language technical interview questions and answers.