list of all c interview questions in this blog _ interview mantra.pdf

Upload: manish-kumar-verma

Post on 14-Apr-2018

219 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    1/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    List of all C interview questions in this blogby S R I D H A R J A M M A L A M A D A K A on N O V E M B E R 1 8 , 2 0 08

    17 Votes

    All the Material available on this site is absolutelyFree! Please support us by subscribing via

    email.

    Enter yo ur email below

    Subscribe

    We do not sell y our em ail or spam .

    Go to Downloads Page to download all the C interviewquestion and answers as a pdf.

    1. What does a static variable mean?

    2. What is a pointer?

    3. What is a structure?

    4. How to print a pattern as shown below?

    1

    2 3

    4 5 6

    7 8 9 10

    5. How to swap two numbers using bitwise operators?

    6. What is recursion? Write a program using recursion (factorial)?

    7. To which numbering system, can the binary number 1101 1001001 11100 be easily converted

    to?

    8. What are the differences between structures and unions?

    9. What are the advantages of using unions?

    10. What is scope & storage allocation of global and extern variables? Explain with an example.

    11 . What is scope & storage allocation of static, local and register variables? Explain with an

    example.

    12. What is Pass by Value? Write a C program showing this concept.

    13. What is Pass by Reference? Write a C program showing this concept.

    14 . What is an Enumeration?

    15. What is the use of typedef?

    16. What are register variables? What are advantages of using register variables?

    17. What are storage memory, default value, scope and life of Automatic and Register storage

    class?

    18. What are storage memory, default value, scope and life of Static and External storage class?

    19. What are the advantages of using pointers in a program?

    20. Which bitwise operator is suitable for chec king whether a particular bit is ON or OFF?

    21. Which bit wise operator is suitable for turning OFF a particular bit in a number?

    22. What do the c and v in argc and argv stand for? Explain their purpose?

    23. What are the differences between malloc() and calloc()?

    24. Where are the auto variables stored?

    25. Out of fgets( ) and gets( ) which function is safer to use and why?

    26. How can you increase the size of a dynamically allocated array?

    http://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2_26.html#staticIdhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2_26.html#fgetshttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2_26.html#autohttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2_26.html#mallochttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2_26.html#argchttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2.html#bitonhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2.html#bitoffhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2.html#pointershttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2.html#staticExternhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-2.html#autoRegisterhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1_26.html#registervariablehttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1_26.html#typedefhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1_26.html#Enumerationhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1_26.html#PassByReferencehttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1_26.html#PassByValuehttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#static/local/registerhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#global/externhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#advantagesUnionhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#struct/unionhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#NumberConversionhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.html#recursionhttp://www.interviewmantra.net/2006/06/c-c-interview-question.html#swapbithttp://www.interviewmantra.net/2006/06/c-c-interview-question.html#patternhttp://www.interviewmantra.net/2006/06/c-c-interview-question.html#structurehttp://www.interviewmantra.net/2006/06/c-c-interview-question.html#pointerhttp://www.interviewmantra.net/2006/06/c-c-interview-question.html#staticvarhttp://www.interviewmantra.net/2009/01/download-pdf-c-interview-questions.htmlhttp://www.interviewmantra.net/author/sridhar-jammalamadaka
  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    2/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    27. Write a program to check whether a given number is even or odd.

    28. Write a program to find the greatest of three numbers.

    29. Write a program to check whether a given number is a prime.

    30. Write a program to find the greatest among ten numbers.

    31. Write a program to swap two numbers using a temporary variable.

    32. Write a program to swap two numbers without using a temporary v ariable.

    33. How to swap two numbers using bitwise operators?

    34. Write a program to check whether a given number is a palindromic number.

    35. Write a program to check whether a given string is a palindrome.

    36. Write a program in C to print Hello World without using semicolon anywhere in the code.

    37. Write a program in C to print a semicolon without using a semicolon anywhere in the code.

    38. Write a program in C to delete a specific line from a text file.39. Write a program in C to replace a specified line in a text file.

    40. Write a program in C to find the number of lines in a text file.

    41 . (i)What are the differences between the C statements below: char *str = Hello;char arr[] =

    Hello;

    (ii)Whether following statements get complied or not? Explain each statement.

    arr++;

    *(arr + 1) = s;

    printf(%s,arr);

    42. Explain the variable assignment in the declaration int *(*p[10])(char *, char * );

    43. What is the value of sizeof(a) /sizeof(char *) in C code snippet below char *a[4]=

    {sridhar,raghava,shashi,srikanth}; explain

    44 . Write a program in C that returns 3 numbers from a function.

    45. In below code snippet:

    struct Date

    {

    int yr;

    int day;

    int month;

    } date1,date2;

    date1.yr = 2004;

    date1.day = 4;

    date1.month = 12;

    Write a function in C that assign values to date2. Arguments to the function must be pointers

    to the structure Date and integer variables date, month, year.

    46. What are header files? Are functions declared or defined in header files ?

    47 . What is the difference between the functions strdup and strcpy in C?

    48. What is difference between for loop and while loop in C language?

    49. Write down the equivalent pointer expression for referring the same element as a[i][j][k][l].50. Which one is equivalent to multiplying an unsigned int by 2, left shifting by 1 or right shifting

    by 1?

    51. Declare an array of three function pointers where each function receives two integers and

    returns float.

    52. Write a program to compare two strings without using strcmp() function.

    53. Write a function to concatenate two strings without using strcat function.

    54. Write a program to generate the fibonacci series

    55.

    Write a C program which asks the user for a number between 1 to 9 and shows the number. If

    the user inputs a number out of the specified range, the program should show an error and

    prompt the user for a valid input.

    56. Write a program to display the multiplication table of a given number.

    57. Write C program to print the following pattern:

    http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques2http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques1http://www.interviewmantra.net/2009/02/fibonacci-strcmp-strcat-programs.html#ques5http://www.interviewmantra.net/2009/02/fibonacci-strcmp-strcat-programs.html#ques4http://www.interviewmantra.net/2009/02/fibonacci-strcmp-strcat-programs.html#ques3http://www.interviewmantra.net/2009/02/fibonacci-strcmp-strcat-programs.html#ques2http://www.interviewmantra.net/2009/02/fibonacci-strcmp-strcat-programs.html#ques1http://www.interviewmantra.net/2009/01/c-interview-questions-answers-5-1.html#ques5http://www.interviewmantra.net/2009/01/c-interview-questions-answers-5-1.html#ques4http://www.interviewmantra.net/2009/01/c-interview-questions-answers-5-1.html#ques3http://www.interviewmantra.net/2009/01/c-interview-questions-answers-5-1.html#ques2http://www.interviewmantra.net/2009/01/c-interview-questions-answers-5-1.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques5http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques4http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques3http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques3http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques2http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques2http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2009/01/function-pointer-structure-pointer.html#ques1http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.html#ques5http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.html#ques4http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.html#ques3http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.html#ques2http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.html#ques1http://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3_26.html#plaindromeStrhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3_26.html#palindromichttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3_26.html#swapBithttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3_26.html#swaphttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3_26.html#swapTemphttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3.html#grt10http://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3.html#primehttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3.html#grt3http://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-3.html#even/odd
  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    3/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    1

    2 2

    3 3 3

    4 4 4 4

    5 5 5 5 5

    58. Write C program to print the following pattern:

    1

    1 2 1

    1 2 3 2 1

    1 2 3 4 3 2 1

    1 2 3 4 5 4 3 2 1

    59. Write a C program to display the following format:

    ------

    a b

    ------

    1 5

    2 4

    3 3

    4 2

    5 1

    ------

    60. Write a C program to display the following format:

    --------

    no. sum

    --------

    1 1

    2 3

    3 6

    4 10

    5 15

    --------

    61. What is the purpose of main() function?

    62. What is the difference

    between declaring a variable and defining a variable?

    63. What are the differences

    between formal arguments and actual arguments?

    64. What is difference between

    getchar and scanf functions for reading strings?

    65. What is difference betweenbreak and continue statements?

    C Interv iew Questions with solutions ebook as a pdf/doc/html

    About th e Aut hor: Sridhar Jam malam adaka is the Editor of Interv iew Mantra. He is a

    student pursuing m asters in International Institute of Information Technology. With ov er 4

    y ear s of IT exper ienc e, h e is obsessed with softwar e progr am mi ng and c ompu ter tech nologies.

    He loves to see a software come to life in it s development life cy cle. He is a person who defies "mob

    mentality " and a deeply spiritual a nd a strong believer of moral v alues and righteousness. Through this

    websit e, h e wi shes to ga th er a lar ge c omm un ity of aspiri ng e ngi neer s, ent repr eneu rs an d professionals

    from all parts of the globe. You can connect with him on Facebook -

    http://www.facebook.com/sridhar.j

    Advertise Register domain name free Advertising Register domain names

    Business Solution Facebook Websites Download All Mantra

    12 comments

    Leave a message...

    Best Community Share

    Shraddha

    1

    http://www.interviewmantra.net/2009/01/download-pdf-c-interview-questions.htmlhttp://www.interviewmantra.net/2009/04/main-getchar-scanf-break-continue.html#ques5http://www.interviewmantra.net/2009/04/main-getchar-scanf-break-continue.html#ques4http://www.interviewmantra.net/2009/04/main-getchar-scanf-break-continue.html#ques3http://www.interviewmantra.net/2009/04/main-getchar-scanf-break-continue.html#ques2http://www.interviewmantra.net/2009/04/main-getchar-scanf-break-continue.html#ques1http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques5http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques5http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques4http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques4http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques3http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques3http://www.interviewmantra.net/2009/04/print-number-pattern-c-programs.html#ques2http://www.shareaholic.com/api/share/?title=List+of+all+C+interview+questions+in+this+blog&link=http://www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html&notes=%0A%0AAll%20the%20Material%20available%20on%20this%20site%20is%20absolutely%20Free%21%20Please%20support%20us%20by%20subscribing%20via%20email.%0A%20Enter%20your%20email%20below%0A%0A%0A%0A%0AWe%20do%20not%20sell%20your%20email%20or%20spam.%0A%0A%0AGo%20to%20Downloads%20Page%20to%20download%20all%20the%20C%20interview%20question%20and%20answers%20as%20a%20pdf.%0A%0A%0A%09What%20does%20a%20static%20variable%20mean%3F%0A%09What%20is&short_link=&shortener=google&shortener_key=&v=1&apitype=1&apikey=8afa39428933be41f8afdb8ea21a495c&source=Shareaholic&template=&service=88&tags=&ctype=http://www.shareaholic.com/api/share/?title=List+of+all+C+interview+questions+in+this+blog&link=http://www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html&notes=%0A%0AAll%20the%20Material%20available%20on%20this%20site%20is%20absolutely%20Free%21%20Please%20support%20us%20by%20subscribing%20via%20email.%0A%20Enter%20your%20email%20below%0A%0A%0A%0A%0AWe%20do%20not%20sell%20your%20email%20or%20spam.%0A%0A%0AGo%20to%20Downloads%20Page%20to%20download%20all%20the%20C%20interview%20question%20and%20answers%20as%20a%20pdf.%0A%0A%0A%09What%20does%20a%20static%20variable%20mean%3F%0A%09What%20is&short_link=&shortener=google&shortener_key=&v=1&apitype=1&apikey=8afa39428933be41f8afdb8ea21a495c&source=Shareaholic&template=&service=52&tags=&ctype=http://www.shareaholic.com/api/share/?title=List+of+all+C+interview+questions+in+this+blog&link=http://www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html&notes=%0A%0AAll%20the%20Material%20available%20on%20this%20site%20is%20absolutely%20Free%21%20Please%20support%20us%20by%20subscribing%20via%20email.%0A%20Enter%20your%20email%20below%0A%0A%0A%0A%0AWe%20do%20not%20sell%20your%20email%20or%20spam.%0A%0A%0AGo%20to%20Downloads%20Page%20to%20download%20all%20the%20C%20interview%20question%20and%20answers%20as%20a%20pdf.%0A%0A%0A%09What%20does%20a%20static%20variable%20mean%3F%0A%09What%20is&short_link=&shortener=google&shortener_key=&v=1&apitype=1&apikey=8afa39428933be41f8afdb8ea21a495c&source=Shareaholic&template=&service=5&tags=&ctype=
  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    4/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    I was asked at the TCS interview:

    How will you write a macro for declaring a 4byte number while using an 8bit

    processor?

    I do know there's typecasting involved but I stumbled while writing the syntax.

    Please ans this if u know Sridhar.

    Regards,

    Shraddha

    13

    Gopi

    I was asked in the interview to print

    0

    1111

    22222222

    3333

    4

    2

    see more

    naren

    Hi gopi,

    This should print the above pattern.,

    /*pattern printing

    0

    1111

    22222222

    3333

    4*/

    printf("\n0");

    for ( i = 0; i 0;i--)

    {

    = < ++ < ="" ************* ="" =""

    Avatar

  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    5/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    see more

    .

    Zythaar

    you are the best man!!!! :-)

    Jdfh

    not that much collection of good codes and problems .

    Vvvraman88

    i want code for the following

    *****

    ****

    ***

    **

    *

    please mail me the code

    my id is : [email protected]

    Idk Lol

    #include

    #include

    void main()

    {

    int i,j,s,nos=0;

    for(i=5 ; i>=1 ; i--)

    {

    for(s=nos ; s>=1 ; s--)

    {

    printf(" ");

    }

    for(j=1 ; j

  • 7/27/2019 List of all C interview questions in this blog _ Interview Mantra.pdf

    6/6

    10/24/13 List of all C interview questions in this blog | Interview Mantra

    www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

    return 2 is same as return 1. For that matter, any non-zero value.

    Does this answer your question? Feel free to ask.

    P R E V I O U S P O S T: C interview questions recursion, unions vs structures, storage allocation of

    variables.

    N E X T P O S T: C interview puzzles semicolon programs, delete or r eplace a line in a text f ile

    http://www.interviewmantra.net/2008/12/c-interview-questions-with-solutions-4.htmlhttp://www.interviewmantra.net/2008/10/c-interview-questions-with-solutions-1.htmlhttps://disqus.com/admin/signup/?utm_source=interviewmantra&utm_medium=Disqus-Footerhttp://disqus.com/