Select chapter



functions (3.papers)
loops (1.papers)
arrays (2.papers)
structures (3.papers)
unions (1.papers)
pointers (7.papers)
null pointers (1.papers)
strings (2.papers)
misc c concepts (1.papers)
Data structures (5.papers)
linked lists (3.papers)
trees (1.papers)
basics (5.papers)
Hide

Sponsored Links


  

c interview questions and answers

Show Answer
Share Facebook gmail Twitter
2
What is a structure in c? Which of the below statements are not true about a struct in C?
  1. structure is a data structure
  2. structure can hold data of heterogeneous data types.
  3. If I want to maintain details of an emp with eno, ename, esal. then it is better to use Array compared to structures.
  4. structure size may not be same as the sum of sizes of all its elements.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
How to declare a structure in C? Which of the below structure declarations are right ?
  1. struct emp
    {
    int eno ;
    char ename[100] ;
    int esal ;
    } ;
    struct emp e1, e2, e3 ;
  2. struct emp
    {
    int eno ;
    char ename[100] ;
    int esal ;
    } e1, e2, e3 ;
  3. struct
    {
    int eno ;
    char ename[100] ;
    int esal ;
    } e1, e2, e3 ;
  4. all are correct.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
9
How to declare a structure in C? Which of the below structure declaration are wrong?
  1. struct emp
    {
        int eno ;
        char ename[100] ;
        int esal ;
    } ;
    
    struct emp e1 = {1, "steve", 1000};
  2. struct emp
    {
        int eno ;
        char ename[100] ;
        int esal ;
    } e1 = {1, "steve", 1000};
  3. struct emp
    {
        int eno ;
        char ename[100] ;
        int esal ;
    } {1, "steve", 1000};
  4. struct
    {
        int eno ;
        char ename[100] ;
        int esal ;
    }e1= {1, "steve", 1000};
Show Answer
Share Facebook gmail Twitter
10
Which of the below statements are correct about a structure declaration in C?
  1. Structure declaration doesn't allocate any memory.
  2. structure declaration should end with a semicolon.
  3. We can place structure declarations in a header file.
  4. all are true.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
14
Structure padding in c with example:

What is the output of below C program? What is the best way to define this structure?
assume int is 4, char is 1 byte.

#include  <stdio.h>

struct stud{
    char a;
    int i;
    char b;
    int j;
    char c;
    int k;
    char d;
    int l;
}s1;
    
main(void)
{
    printf("%d", sizeof(s1));
    return 0;
}
  1. it prints 20. there is no problem with this, no need to redefine it.
  2. it prints 32. there is no need to redefine it.
  3. it prints 32. its better to define like this. struct stud{
        char a,b,c,d;
        int i,j,k,l;
    }s1;
  4. it prints 20. its better to define like this. struct stud{
        char a,b,c,d;
        int i,j,k,l;
    }s1;
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
17
What is "floating point formats not linked" error means?
  1. That means system architecture is not supported to calculate floating point arithmetic.
  2. Some compilers leave out certain floating point support.
    to save space, they use printf & scanf version which do not have
    support to handle %e, %f, and %g.
  3. both option1 & 2 are correct.
  4. compilers which don't have library support for printf & scanf functions will raise this kind of errors.
Show Answer
Share Facebook gmail Twitter
18
What is the solutions to resolve "floating point formats not linked" error?
  1. call sqrt functions in your code to link floating point libraries to your code.
  2. write below functions in your code
    
    linkfloat( )
    {
            float s = 0;
            float *t;
            s = &t ; 
            s = *t ; 
    }
  3. either we can use option 1 or option 2.
  4. If compiler don't support it, then we have to use a different compiler designed to handle floating point calculations.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :