{"id":208,"date":"2019-11-30T08:00:46","date_gmt":"2019-11-30T08:00:46","guid":{"rendered":"http:\/\/52.66.89.59\/?p=208"},"modified":"2022-04-14T06:10:53","modified_gmt":"2022-04-14T06:10:53","slug":"top-50-c-programming-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/","title":{"rendered":"Top 50 C Programming Interview Questions and Answers"},"content":{"rendered":"<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\" alt=\"\" \/>\n<p><br>\n<br><\/p>\n\n<p><strong>Q1. You know what are Increment and Decrement operators correct?&nbsp; What I want to know is how increment and decrement operators can be constructed using basic mathematical operators?<\/strong><\/p>\n\n\n<p>Ans. (<em>First, in a line explain Increment and Decrement operators then answer the question<\/em>)<\/p>\n\n\n<p>Increment and Decrement operators are used to increase or decrease the value of the variable by 1. We can achieve this functionality by using&nbsp; &#8216;+&#8217; and &#8216;-&#8216; operators. For eg:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    int x=1;\n    int y= x++; \/\/ this can be divided into two steps (y=x; x=x+1;)\n    int z= --x; \/\/ this can be divided into two steps (x=x+1; z=x;)\n    <\/code><\/pre>\n\n\n<p>(<em>Such example will show your understanding of post and pre, increment\/decrement also<\/em>)<\/p>\n\n\n<p><strong>Q2. How will you print \u201cHello World\u201d without using semicolon even once in your code?<\/strong><\/p>\n\n\n<p>Ans. (<em>Simply write the below code and explain it\u2019s working<\/em>)<\/p>\n\n\n<pre class=\"wp-block-preformatted\">    int main(void)\n    {\n        if(printf(\u201cHello World\u201d))\n        {\n        }\n    }\n\n<\/pre>\n\n\n<p>printf() function will print \u201cHello World\u201d to the console. It will return a non-zero value to&nbsp;<em>if<\/em> statement and there is no other code to execute.<\/p>\n\n\n<p>(<em>Interesting fact<\/em>: printf returns the number of characters(including space) inside the inverted quotes according to data structures using c. For the above example, it will return 11.)<\/p>\n\n\n<p><strong>Q3.<\/strong>&nbsp;<strong>Do you know how many places a variable can be declared in C? If you do, then mention the places and the type of variable corresponding to that place.<\/strong><\/p>\n\n\n<p>Ans. (<em>Name all the 3 places where the variables can be declared<\/em>)<\/p>\n\n\n<p>Variables can be declared in 3 places:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Inside functions<\/li><li>In the definition of function parameters<\/li><li>Outside all functions.<\/li><\/ol>\n\n\n<p>These positions correspond to<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Local variables<\/li><li>Formal parameters<\/li><li>Global variables<\/li><\/ol>\n\n\n<p><strong>Q4. Explain Local variables, Formal parameters and Global variables.<\/strong><\/p>\n\n\n<p>Ans.&nbsp;Local Variables:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Variables that are declared inside a function are called local variables.<\/li><li>Local variables exist only while the block of code in which they are declared is executing, i.e., a local variable is created upon entry into its block and destroyed upon exit.<\/li><\/ol>\n\n\n<p>(<em>Interesting fact<\/em>: A variable declared within one block has no relationship to another variable with the same name declared within a different code block.)<\/p>\n\n\n<p>Formal Parameters:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>If a function is to use arguments, it must declare variables that will accept the values of the arguments. These variables are called the formal parameters of the function.<\/li><li>They behave like any other local variables inside the function.<\/li><\/ol>\n\n\n<p>Global Variables:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Global variables are declared outside any function.<\/li><li>Unlike local variables, global variables are known throughout the program and may be used by any piece of code.<\/li><li>Also, they will hold their value throughout the program&#8217;s execution.<\/li><\/ol>\n\n\n<p>(<em>Interesting fact<\/em>: After defining a local variable, the system or the compiler won&#8217;t be initializing any value to it.<\/p>\n\n\n<p>Global variables get initialized automatically by the compiler as and when defined based on datatype. int = 0, char = &#8221;, float = 0, double = 0 and pointer = Null)<\/p>\n\n\n<p><strong>Q5. Explain to me the concept of Null pointer. And if you can, shed some light on Dangling pointer as well.<\/strong><\/p>\n\n\n<p>Ans. If the pointer variable is not assigned any valid memory address then NULL can be used to initialize that pointer. (Conceptually, the NULL pointer doesn&#8217;t point anywhere)<\/p>\n\n\n<p>(<em>Interesting fact<\/em>: we have a void pointer as well. A pointer that points to some data location in storage, which doesn&#8217;t have any specific type, so &#8220;void&#8221; pointer).<\/p>\n\n\n<p>Dangling pointer: Pointer that doesn&#8217;t point to a valid memory location. (<em>Don&#8217;t stop here it will give the interviewer a chance to confuse you, provide a detailed answer<\/em>)<\/p>\n\n\n<p>If you delete or deallocate a memory of an object without modifying the pointer pointing to it, in such cases dangling pointer arises.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    int* dang = (int *)malloc(sizeof(int));\n    free(dang); \/\/ deallocated the memory used by the dang variable.\n    *dang = 100; \/\/ now the pointer is pointing to invalid memory locations. So, this becomes a dangling pointer.\n    <\/code><\/pre>\n\n\n<p><strong>Q6. In a C language, how many ways are there of passing arguments to a subroutine(function)?<\/strong><\/p>\n\n\n<p>Ans. In C language there are two ways that arguments can be passed to a subroutine.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Call by Value<\/li><li>Call by Reference<\/li><\/ol>\n\n\n<p>(Now explain these two points)<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Call by Value: This method copies the&nbsp;<em>value<\/em>&nbsp;of an argument into the formal parameter of the subroutine. In this case, changes made to the parameter&nbsp;<em>do not affect<\/em>&nbsp;<em>the argument<\/em>. (This is how we pass the arguments usually)<\/li><li>Call by Reference: In this method, the&nbsp;<em>address of an argument is copied<\/em>&nbsp;into the parameter. Inside the subroutine, the address is used to access the actual argument used in the call. This means that changes made to the parameter&nbsp;<em>affect the argument<\/em>. (This is when pointers arrive into the picture)<\/li><\/ol>\n\n\n<p>(<em>You can stop here, or you can also provide a simple Swap function example for Call by Reference<\/em>)<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    void swap(int *x, int *y)\n    {\n        int temp;\n    temp=*x;\u00a0 \/\/ store the value present at address of \u2018x\u2019\n    *x=*y;\u00a0\u00a0\u00a0 \/\/ copy the value present at the address of \u2018y\u2019 to address of \u2018x\n    *y=temp;\u00a0 \/\/ copy the value present in temp to address of \u2018y\u2019\n    }\n    int main(void)\n    {\n    int i=10, j=20;\n    swap(&amp;i, &amp;j);\n    printf(\"i=%d and j=%d\",i,j);\n    return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q7. Is there a way in C programming such that the local variables maintain their values between function calls?<\/strong><\/p>\n\n\n<p>(Sometimes a question is not asked directly, such as above question could be asked simply as &#8211;&nbsp;<em>Explain use of static keyword in C language<\/em>)<\/p>\n\n\n<p>Ans. (<em>First, explain&nbsp;<strong>static<\/strong>&nbsp;keyword<\/em>)<\/p>\n\n\n<p>Variables declared as&nbsp;<strong>static<\/strong>&nbsp;are permanent variables within their own function or file. They are not known outside their function or file.<\/p>\n\n\n<p>(<em>Now, explain only about&nbsp;<strong>static<\/strong>&nbsp;Local Variable, no need to explain about&nbsp;<strong>static<\/strong>&nbsp;Global Variables<\/em>)<\/p>\n\n\n<p><strong>static<\/strong>&nbsp;Local Variables: When you apply the&nbsp;<strong>static<\/strong>&nbsp;modifier to a local variable, the compiler creates permanent storage for it, much as it creates storage for a global variable.<\/p>\n\n\n<p>The key difference between a&nbsp;<strong>static<\/strong>&nbsp;local variable and a global variable is that the&nbsp;<span style=\"background-color: rgba(25, 30, 35, 0.2);\"><b>stati<\/b><\/span><strong>c local<\/strong> variable remains known only to the block in which it is declared.<\/p>\n\n\n<p>In simple terms, a&nbsp;<strong>static<\/strong>&nbsp;local variable is a local variable that retains its value between function calls.<\/p>\n\n\n<pre class=\"wp-block-preformatted\"> <code>\n    #include &lt;stdio.h&gt;\n    int product();\n    int main()\n    {\n    product();\n    return 0;\n    }\n    int product()\n    {\n    static int var = 1; \/\/ var initialized to 1\n    var=var*5; \/\/ updates value of var, this will be retained after recursive call as well\n    if(var&gt;1000)\n        return;\n    printf(\"%d, \", var);\n    product();\n    }\n<\/code>\n<\/pre>\n\n\n<p><strong>Q8.&nbsp;<\/strong><strong>You can easily print numbers from 1 to 100 using a loop, can you do the same without using any type of loop?<\/strong><\/p>\n\n\n<p>Ans. (Use recursion instead loop)<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    void printNumbers(int);\n    int main()\n    {\n        int n=1;\n        printNumbers(n);\n        return 0;\n    }\n    void printNumbers(int n)\n    {\n        if(n&lt;=100)\n        {\n            printf(\"%d  \", n);\n            printNumbers(n+1);\n        }\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q9.&nbsp;<\/strong><strong>In the lines&nbsp;<\/strong><strong>#include &lt;stdio.h&gt;<\/strong><strong>,&nbsp;<\/strong><strong>#define MOD 10000007<\/strong><strong>, what are #include and #define?<\/strong><\/p>\n\n\n<p>Ans. (<em>Interviewer is expecting an explanation of Preprocessor Directives<\/em>)<\/p>\n\n\n<p>#include and #define are Preprocessor directives. Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, another use is to declare constants. Preprocessors are programs that process our source code before compilation.<\/p>\n\n\n<p><strong>#include<\/strong>&nbsp;&#8211; It is used to include libraries, which would depend on what functions are to be used in the program.<\/p>\n\n\n<p><strong>#define<\/strong>&nbsp;&#8211; It defines an identifier and a character sequence that will be substituted for the identifier each time it is encountered in the source file. The identifier is referred to as a&nbsp;<em>macro name<\/em>&nbsp;and the replacement process as&nbsp;a <em>macro replacement<\/em>.<\/p>\n\n\n<p>(<em>Interesting fact<\/em>: Each preprocessing directive must be on its own line. For example, this will not work -&gt; #include &lt;stdio.h&gt; #include&lt;stdlib.h&gt; )<\/p>\n\n\n<p><strong>Q10. Explain about Entry control and Exit control loops in C.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Entry control: This loop is categorized in 2 part<ol><li>while loop<\/li><li>for loop<\/li><\/ol><\/li><li>Exit control: In this category, there is only one type of loop known as<ol><li>do while loop<\/li><\/ol><\/li><\/ol>\n\n\n<p><strong>Q11. Memory layout of C consist of Text, Data, Stack and Heap areas, explain about stack and heap areas?<\/strong><\/p>\n\n\n<p>Ans.&nbsp;Stack Area: It is used to store local variables and&nbsp;is used for&nbsp;<strong>passing arguments<\/strong>&nbsp;to the functions along with the return address of the instruction which is to be executed after the function call is over. These values stay in the memory only till the termination of that function.<\/p>\n\n\n<p>Heap Area: Heap is a segment where dynamic memory allocation usually takes place. In C language dynamic memory allocation is done by using malloc() and calloc() functions.<\/p>\n\n\n<p><strong>Q12. In which memory segment of the C program, static variables are stored?<\/strong><\/p>\n\n\n<p>Ans. (There are two cases here, explain both to the interviewer)<\/p>\n\n\n<ol class=\"wp-block-list\"><li>static variables that do not have an explicit initialization or are initialized to zero are stored in the uninitialized data segment(also known as the BSS segment).<\/li><li>static variables that are initialized are stored in the initialized data segment.<\/li><\/ol>\n\n\n<p>&nbsp;<strong>Q13. What functions are used for dynamic memory allocation in C language?<\/strong><\/p>\n\n\n<p>Ans. Standard C defines four dynamic allocation functions that all compilers will supply:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>calloc()<\/li><li>malloc()<\/li><li>free()<\/li><li>realloc()<\/li><\/ol>\n\n\n<ol class=\"wp-block-list\"><li>calloc() :<ol><li>The&nbsp;<strong>calloc()<\/strong>&nbsp;function takes two arguments (n, sizeof n), and allocated (n*size) memory. That is,&nbsp;<strong>calloc()<\/strong>&nbsp;allocates enough memory for an array of&nbsp;<em>num<\/em>objects of size&nbsp;<em>size<\/em>. All bits in the allocated memory are initially set to zero.<\/li><li>The&nbsp;<strong>calloc()<\/strong>&nbsp;function returns a pointer to the first byte of the allocated region. If there is not enough memory to satisfy the request, a null pointer is returned.<\/li><\/ol><\/li><li>malloc():<ol><li>The&nbsp;<strong>malloc()<\/strong>&nbsp;function returns a pointer to the first byte of a region of memory of <em>size<\/em>&nbsp;that has been allocated from the heap.<\/li><li>If there is insufficient memory in the heap to satisfy the request,&nbsp;<strong>malloc()<\/strong>returns a null pointer.<\/li><\/ol><\/li><li>free():<ol><li>The&nbsp;<strong>free()<\/strong>&nbsp;function deallocates the memory assigned to a pointer by one of the dynamic allocation functions.<\/li><li>This makes the memory available for future allocation.<\/li><\/ol><\/li><li>realloc():<ol><li>In simple English,&nbsp;<strong>realloc()<\/strong>&nbsp;is used to change the size of previously allocated memory pointed to by the pointer.<\/li><li>For C89,&nbsp;<strong>realloc()<\/strong>&nbsp;changes the size of the previously allocated memory pointed to by&nbsp;<em>ptr<\/em>&nbsp;to that specified by&nbsp;<em>size<\/em>.<\/li><li>For C99, the block of memory pointed to by&nbsp;<em>ptr<\/em>&nbsp;is freed, and a new block of specified&nbsp;<em>size<\/em>&nbsp;is allocated, and the previous content is copied.<\/li><\/ol><\/li><\/ol>\n\n\n<p><strong>Q14. Can we convert a higher data type into a lower data type in C? If yes, then how?<\/strong><\/p>\n\n\n<p>Ans. (Typecasting is asked here)<\/p>\n\n\n<p>Yes, we can convert higher data type into lower data type using explicit typecasting.&nbsp;<strong>Typecasting<\/strong>&nbsp;is a way to convert a variable from one data type to another data type.<\/p>\n\n\n<p>But it is not a good practice to convert the higher data type to lower data type, because data will be truncated when the higher data type is converted into a lower data type, resulting in data loss.<\/p>\n\n\n<p>If a float is converted to int, then we will lose values after decimal point (5.550 -&gt; 5, a loss of .550).<\/p>\n\n\n<p><strong>Q15. Explain all the types of recursion.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Linear Recursion<ol><li>In linear recursion, a function calls exactly once to itself each time the function is invoked.<\/li><li>For ex: Find maximum in an Array.<\/li><li>As you can see in the above code, recursiveMax() is called exactly ones each time the function is called.<\/li><li>Also keep in mind, though recursiveMax() call is in the last statement, it is not the last operation, the last operation here is returning Maximum element.<\/li><\/ol><\/li><li>Tail Recursion<ol><li>Tail recursion is another form of linear recursion, where the function makes a recursive call as its very last operation.<\/li><li>For example, printing 1 to 100<\/li><li>Here printNumbers() is the last operation, so it is tail recursion.<\/li><\/ol><\/li><li>Binary Recursion<ol><li>In binary recursion a function makes two recursive calls to itself when invoked.<\/li><li>For example, Fibonacci series using recursion.<\/li><\/ol><\/li><li>Multiple Recursion<ol><li>Multiple recursion can be treated as a generalized form of binary recursion.<\/li><li>When a function makes multiple recursive calls probably more than two, it is called multiple recursion.<\/li><\/ol><\/li><\/ol>\n\n\n<p><strong>Q16. Write a program to swap two numbers without using the third variable?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h>\nint main()\n{\n    int x=50, y=60;\n    x=x+y; \/\/ x=110 (50+60)\n    y=x-y; \/\/ y=110-60 =50\n    x=x-y; \/\/ x=110-50 =60\n    \/\/ so now x=60 and y=50.\n    printf(\u201cx=%d and y=%d\u201d,x,y);\n    return 0;\n}\n<\/code><\/pre>\n\n\n<p><strong>Q17. Write a program to find the Fibonacci series without using recursion?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    void main()\n    {\n        int num1=0,num2=1,num3,i,number;\n        printf(\"Enter the number of elements: \");\n        scanf(\"%d\",&amp;number);\n        printf(\"%d %d\",num1,num2);\n        for(i=2;i&lt;number;i++)\n        {\n            num3=num1+num2;\n            printf(\" %d\",num3);\n            num1=num2;\n            num2=num3;\n        }\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q18. Write a program to print Fibonacci series using recursion?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    int fib(int);\n    int main()\n    {\n        int num=0,i,n;\n        scanf(\"%d\",&amp;n);\n        printf(\"Fibonacci series: \n\");\n        for(i=1;i&lt;=n;i++)\n        {\n            printf(\"%d \",fib(num));\n            num++;\n        }\n    }\n    int fib(int n);\n    {\n        if(n==0 || n==1)\n            return n;\n        else\n            return (fib(n-1))+fib(n-2));    \n    }\n<\/code><\/pre>\n\n\n<p><strong>Q19. Write a C program to check whether a number is Prime or not.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    #include&lt;math.h>\n    int main()\n    {\n        int num,i;\n        int flag=0;\n        printf(\"Enter any positive number: \n\");\n        scanf(\"%d\",&amp;num);\n        for(i=2;i&lt;=sqrt(num);i++)\n        {\n            if(num%i==0)\n            {\n                flag=1;\n                break;\n            }\n        }\n        if(flag==0)\n        {\n            printf(\"%d is Prime Number\",num);\n        }\n        else\n        {\n            printf(\"%d is not a Prime Number\",num);\n        }\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q20. Write a program to check whether the number is prime or not using recursion.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-preformatted\">    #include&lt;stdio.h&gt;\n    int isPrime(int,int);\n    int main()\n    {\n        int n,i=2;\n        printf(\"Enter any positive number: \n\");\n        scanf(\"%d\",&amp;n);\n        if(isPrime(n,i)==1)\n        {\n            printf(\"Yes\");\n        }\n        else\n        {\n            printf(\"No\");\n        }\n    }\n    int isPrime(int n, int i)\n    {\n        if(n&lt;2)\n            return 0;\n        if(n==2)\n            return 1;\n        if(n%i==0)\n            return 0;\n        if(i*i &gt; n)\n            return 1;\n        return isPrime(n,i+1);\n    }\n\n<\/pre>\n\n\n<p><strong>Q21. Write a program to check whether a number is Palindrome number or not in C programming.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-preformatted\">    #include&lt;stdio.h&gt;\n    int main()\n    {\n        int num,rem,sum=0,temp;\n        printf(\"enter the number=\");\n        scanf(\"%d\",&amp;num);\n        temp=num;\n        while(num&gt;0)\n        {   \n            rem=num%10;\n            sum=(sum*10)+rem;\n            num=num\/10;\n        }\n        if(temp==sum)\n            printf(\"Palindrome number \");\n        else\n            printf(\"Not palindrome\");\n        return 0;\n    }\n\n<\/pre>\n\n\n<p><strong>Q22. Write a program to print factorial (without recursion) in C programming.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-preformatted\">    #include&lt;stdio.h&gt;\n    int main()\n    {\n        int i,fact=1,num;\n        printf(\"Enter a number: \");\n         scanf(\" %d \",&amp;numb);\n        for(i=1;i&lt;=numb;i++)\n        {\n            fact=fact*i;\n        }\n        printf(\"Factorial of %d is: %d\",num,fact);\n        return 0;\n    }\n\n<\/pre>\n\n\n<p><strong>Q23. Write a program to print factorial (using recursion) in C programming.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    long int factorial(int n);\n    int main()\n    {\n        int n;\n        printf(\"Enter a positive integer: \");\n        scanf(\"%d\", &amp;n);\n        printf(\"Factorial of %d = %ld\", n, factorial(n));\n        return 0;\n    }\n    long int factorial(int n)\n    {\n        if (n >= 1)\n            return n*factorial(n-1);\n        else\n            return 1;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q24. Write a C program to check whether a number is Armstrong or not.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    #include &lt;math.h>\n    int main()\n    {\n        int number, tempNum, rem, result = 0, n = 0 ;\n        printf(\"Enter an integer: \");\n        scanf(\"%d\", &amp;number);\n        tempNum = number;\n        while (tempNum != 0)\n        {\n            tempNum \/= 10;\n            ++n;\n        }\n        tempNum = number;\n        while (tempNum != 0)\n        {\n            rem = tempNum%10;\n            result += pow(rem, n);\n            tempNum \/= 10;\n        }\n        if(result == number)\n            printf(\"%d is an Armstrong number.\", number);\n        else\n            printf(\"%d is not an Armstrong number.\", number);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q25. Write a C program to reverse an Integer.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    int main()\n    {\n        int n, reverseNum = 0, rem;\n        printf(\"Enter an integer: \");\n        scanf(\"%d\", &amp;n);\n        while(n != 0)\n        {\n            rem = n%10;\n            reverseNum = reverseNum*10 + rem;\n            n \/= 10;\n        }\n        printf(\"Reversed Number = %d\", reverseNum);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q26. Write a C program to find the sum of two integers without using &#8216;+&#8217; operator.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    int main()\n    {\n        int x=10;\n        int y=20;\n        int sum = -(-x-y); \/\/ -(-x-y)= x+y, simple mathematics trick\n        printf(\"%d\",sum);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q27. Write a C program to print \u201cHello World\u201d with the double-quotes.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    int main()\n    {\n        printf(\"\"Hello World\"\");\/\/ use escape sequence\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q28. Write a C program to divide an integer by 2 without using \u2018\/\u2019 operator.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    int main()\n    {\n        int n=56;\n        printf(\"%d\", n>>1);\n    }\n<\/code><\/pre>\n\n\n<p><em>(Interesting fact: Right shift operator is used to divide a number by powers of 2. N&gt;&gt;1 == N\/2, N&gt;&gt;2 == N\/4, N&gt;&gt;3 == N\/8. Same is the case with Left shift operator, it is used for multiplication.)<\/em><\/p>\n\n\n<p><strong>Q29. Write a C program to reverse a String in C with the help of recursion.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include&lt;stdio.h>\n    void reverseStr(char[]);\n    void reverseStr(char str[])\n    {\n        if(str[0]!='')\n        {\n            reverseStr(str+1);\n            printf(\"%c\",str[0]);\n        }\n    }\n    int main()\n    {\n        char str[] =\"PrepBytes\";\n        reverseStr(str);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q30. Can the size of an array be declared at runtime in C?<\/strong><\/p>\n\n\n<p>Ans. No, in array declaration, the size must be known at compile time. You can\u2019t specify a size that\u2019s known only at runtime. The compiler needs to store memory for the array, and to do that compiler requires Array\u2019s size at compile.<\/p>\n\n\n<p>For example:<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    int size;\n    int arr[size]; \/\/ this is wrong as size is not initialized yet.\n    \/\/ The correct code is\n    int size;\n    scanf(\u201c%d\u201d, &amp;size);\n    int arr[size];\n<\/code><\/pre>\n\n\n<p><strong>Q31. Write a C program to convert String into Integer without using library function.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    #include &lt;string.h>\n    int main()\n    {\n        char str[10]; \/\/ any string greater than 10, will be outside integer range.\n        int num = 0, i, j, len;\n        printf(\"Enter a number String: \");\n        gets(str);\n        len = strlen(str);\n        for(i=0; i&lt;len; i++){\n            num = num * 10 + ( str[i] - '0' );\n        }\n        printf(\"%d\", num);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q32. Write a C program to convert an integer into a string without using library function.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    #include &lt;string.h>\n    int main()\n    {\n        int num,result,rem,len=0,n,i;\n        char str[10];\n        printf(\"Enter a number: \");\n        scanf(\"%d\",&amp;num);\n        n=num;\n        while(n!=0)\n        {\n            len++;\n            n=n\/10;\n        }\n        for(i=0;i&lt;len;i++)\n        {\n            rem=num%10;\n            num=num\/10;\n            str[len-(i+1)]=rem+'0';\n        }\n        str[len]='';\n        printf(\"%s\",str);\n        return 0;\n    }\n<\/code><\/pre>\n\n\n<p><strong>Q33. What is the difference between Macros and Functions?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><th>Macros<\/th><th>Functions<\/th><\/tr><tr><td>Macro is Pre-processed<\/td><td>Function is compiled<\/td><\/tr><tr><td>No type checking is done in Micro<\/td><td>Type checking is done in function<\/td><\/tr><tr><td>Use of Micro can lead to side effect at later stages<\/td><td>Functions do not lead to any side effect in any case<\/td><\/tr><tr><td>Speed of execution using Micro is faster<\/td><td>Speed of execution using function is slower<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<p><strong>Q34. How will you find the total number of elements in the array if the size of the array is not provided?<\/strong><\/p>\n\n\n<p>Ans. We will use \u201csizeof\u201d operator to calculate number of elements in the array.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    int main()\n    {\n        int arr[]={1,2,3,4,5,6,7,8,9,10};\n        printf(\u201cNumber of elements: %d\u201d,sizeof(arr)\/sizeof(arr[0]); \/\/ sizeof(arr) = 40 , sizeof(arr[0])=4 for integer size=4\n        return 0;\n    }\n\n    O\/p = 10\n<\/code><\/pre>\n\n\n<p><strong>Q35. Do all character arrays end with \u201cnul\u201d() character in C?<\/strong><\/p>\n\n\n<p>Ans. All character arrays are not null-terminated in C. Strings are special character arrays that are null-terminated.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>char arr[3] = {\u2018a\u2019,\u2019b\u2019,\u2019c\u2019}; is not a null-terminated character array.<\/li><li>char arr[] = \u201cPrepBytes\u201d; is a null-terminated string. These are known as String constants.<\/li><\/ol>\n\n\n<p><strong>Q36. Describe how arrays can be passed to a user-defined function.<\/strong><\/p>\n\n\n<p>Ans. We cannot pass an entire array in the form of arguments. Instead, while calling a function we pass the address of the first element of the array(name of the array) as formal arguments, a pointer is used to point to this address.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    int main()\n    {\n        int arr[5]={1,2,3,4,5};\n        ............\n        func(arr);\n        ............\n    }\n    void func(int arr[]) or void func(int *arr)\n<\/code><\/pre>\n\n\n<p><strong>Q37. &nbsp;What are self-referential structures? Are they possible in C?<\/strong><\/p>\n\n\n<p>Ans. Self-referential structures are those structures that have one or more pointers that point to the same type of structure, as their member.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    struct node{\n        int data1;\n        struct node* link;\n    };\n<\/code><\/pre>\n\n\n<p>Yes, self-referential structures are possible in C.<\/p>\n\n\n<p><strong>Q38. What are the different ways to access structure members in C?<\/strong><\/p>\n\n\n<p>Ans. They are two operators using which we can access structure members<\/p>\n\n\n<ol class=\"wp-block-list\"><li>(.) dot operator<\/li><li>(-&gt;) arrow operator<\/li><\/ol>\n\n\n<p>Syntax: (structure name) .(member name) , (structure name) -&gt;(member name)<\/p>\n\n\n<p>The difference between them is in the case of pointers.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    struct node\n    {\n        int i;\n        int j;\n    }\n    struct node a,*p;\n    p=&a;\n<\/code><\/pre>\n\n\n<p>Here, \u2018a\u2019 is a structure of type node, and \u2018p\u2019 is a pointer to a structure of type node.<\/p>\n\n\n<p>Now accessing elements with the help of \u2018a\u2019 is straight forward- a.i and a.j<\/p>\n\n\n<p>But using \u2018p\u2019 is tricky. (*p.i) if we right like this, then precedence and associativity will arrive in the picture. The compiler will read (*p.i) as (*(p.i)) which is wrong, so you need to manage parenthesis as well, i.e. right correctly ((*p).i), so to reduce programming errors (-&gt;) operator is provided in case of pointers. Using arrow operators we can simply write<\/p>\n\n\n<p>(p-&gt;i) and (p-&gt;j) to access members of structure node using pointers.<\/p>\n\n\n<p><strong>Q39. What is the main advantage of using Structures in C?<\/strong><\/p>\n\n\n<p>Ans. Structures can store heterogeneous types of data under a single name. Unlike arrays, we can store int, float, char any type of data inside structures and then access and manipulate this data.<\/p>\n\n\n<p><strong>Q40. What are the advantages and disadvantages of storing data in the heap area?<\/strong><\/p>\n\n\n<p>Ans. Storing data on a heap is comparatively slower than storing data on slack. The main advantage is the flexibility provided by the heap area. Memory in the heap area can be allocated and deallocated in any particular order.<\/p>\n\n\n<p><strong>Q41. What is a Storage class in C?<\/strong><\/p>\n\n\n<p>Ans. Storage class in C decides the part of storage to allocate memory for a variable, it also determines the scope of a variable. All variables defined in a C program get some physical location in memory where the variable\u2019s value is stored. Along with the lifetime of a variable, storage class also determines the variable&#8217;s storage location (memory or registers), the scope (visibility level) of the variable, and the initial value of the variable. There are four storage classes in C that are automatic, register, static and external.<\/p>\n\n\n<p><strong>Q42. Describe Storage class Specifiers.<\/strong><\/p>\n\n\n<p>Ans. There are four storage class specifiers in C<\/p>\n\n\n<ol class=\"wp-block-list\"><li>auto<\/li><li>register<\/li><li>extern<\/li><li>static<\/li><\/ol>\n\n\n<p>These specifiers tell the compiler how to store the subsequent variable. The general form of a variable declaration that uses a storage class is:<\/p>\n\n\n<p>Storage_class_specifier data_type variable_name;<\/p>\n\n\n<p>At most one storage class specifier may be given in a declaration.<\/p>\n\n\n<p><em>(Detailed explanation in the next question)<\/em><\/p>\n\n\n<p><strong>Q43. Describe types of Storage classes.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Automatic storage class:<ol><li>A variable defined within a function or a block with (auto) specifier belongs to the automatic storage class.<\/li><li>All variables defined within a function or block by default belong to automatic storage class if no storage class is mentioned.<\/li><\/ol><\/li><li>Register storage class:<ol><li>The (register) specifier declares a variable of the register storage class.<\/li><li>Variables belonging to the register storage class are local to the block which they are defined in, and get destroyed on exit from the block,<\/li><li>A (register) declaration is equivalent to an (auto) declaration, but hints that the declared variable will be accessed frequently; therefore, they are placed in CPU registers, not in memory.<\/li><\/ol><\/li><li>Static storage class:<ol><li>The (static) specifier gives the declared variable static storage class.<\/li><li>Static variables can be used within function or file. Unlike global variables, static variables are not visible outside their function or file, but they maintain their values between calls.&nbsp;<\/li><\/ol><\/li><li>Extern Storage class:<ol><li>The (extern) specifier gives the declared variable external storage class.<\/li><li>A declaration declares the name and type of a variable or function. A definition causes storage to be allocated for the variable or the body of the function to be defined.<\/li><li>When&nbsp;extern specifier is used with a variable declaration then no storage is allocated to that variable and it is assumed that the variable has already been defined elsewhere in the program. When we use&nbsp;extern&nbsp;specifier the variable cannot be initialized because with&nbsp;extern&nbsp;specifier variable is declared, not defined.<\/li><\/ol><\/li><\/ol>\n\n\n<p><strong>Q44. If storage classes are responsible for scope and memory storage of variables, then why don\u2019t we normally write them with each variable in the code?<\/strong><\/p>\n\n\n<p>Ans. Default rules that are used if no storage class specifier is specified are:<\/p>\n\n\n<ol class=\"wp-block-list\"><li>Variables declared inside the function are taken to be (auto).<\/li><li>Functions declared within a function are taken to be (extern).<\/li><li>Variables and functions declared outside a function are taken to be (static), with external linkage.<\/li><\/ol>\n\n\n<p><strong>Q45. Suppose a global variable and local variable have the same name. Is it possible to access a global variable from a block where a local variable is defined in C?<\/strong><\/p>\n\n\n<p>Ans. No, it is not possible in C. It is always the most local variable that gets preference.<\/p>\n\n\n<p><strong>Q46. What is a sequential access file?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>When writing programs that will store and retrieve data in a file, it is possible to designate that file into different forms.<\/li><li>A sequential access file is such that data are saved in sequential order: one data is placed into the file after another.<\/li><li>To access a particular data within the sequential access file, data has to be read one data at a time, until the right one is reached.<\/li><\/ol>\n\n\n<p><strong>Q47. What is a translation unit?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>A translation unit is a set of files seen by the compiler.<\/li><li>It includes the source code under consideration and files that are included such as header files and other disk files contain C code.<\/li><\/ol>\n\n\n<p><strong>Q48. Find the maximum &amp; minimum of two numbers in a single line without using any condition &amp; loop.<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<pre class=\"wp-block-code\"><code>\n    #include &lt;stdio.h>\n    #include&lt;stdlib.h>\n    int main()\n    {\n        int a=15,b=30;\n        printf (\"max = %d, min = %d\", ((a+b) + abs(a-b))\/2, ((a+b) - abs(a-b)) \/2);\n        return 0;\n    }\n\nO\/p: max=30, min=15\n<\/code><\/pre>\n\n\n<p><strong>Q49. What is a FILE pointer in C?<\/strong><\/p>\n\n\n<p>Ans.<\/p>\n\n\n<ol class=\"wp-block-list\"><li>A File pointer is a pointer that is used to handle and keep track on the files being accessed. A new data type called \u201cFILE\u201d is used to declare file pointer. This data type is defined in stdio.h file. The file pointer is declared as FILE *fp. Where \u2018fp\u2019 is a file pointer.<\/li><li>fopen() function is used to open a file that returns a FILE pointer. Once file is opened, file pointer can be used to perform I\/O operations on the file. fclose() function is used to close the file.<\/li><\/ol>\n\n\n<p><strong>Q50. What is the difference between an uninitialized pointer and a null pointer?<\/strong><\/p>\n\n\n<p>Ans. An uninitialized pointer is a pointer that points unknown memory location while the null pointer is pointer which points a null value or base address of the segment.<\/p>\n\n<p>This article tried to discuss <strong>Top 50 C Programming Interview Questions and Answers<\/strong>. Hope this blog helps you understand the concept. If you wish to prepare for placements you can <a href=\"https:\/\/www.prepbytes.com\/placement-preparation-program\">join prepbytes placement program to get your dream job<\/a><\/h6><\/p>\n<!-- \/wp:post-content -->","protected":false},"excerpt":{"rendered":"<p>Q1. You know what are Increment and Decrement operators correct?&nbsp; What I want to know is how increment and decrement operators can be constructed using basic mathematical operators? Ans. (First, in a line explain Increment and Decrement operators then answer the question) Increment and Decrement operators are used to increase or decrease the value of [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[140],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-c-programming","tag-c-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C Programming Interview Questions | Prepbytes |<\/title>\n<meta name=\"description\" content=\"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C Programming Interview Questions | Prepbytes |\" \/>\n<meta property=\"og:description\" content=\"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-30T08:00:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-14T06:10:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\" \/>\n<meta name=\"author\" content=\"PrepBytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PrepBytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"22 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\"},\"author\":{\"name\":\"PrepBytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\"},\"headline\":\"Top 50 C Programming Interview Questions and Answers\",\"datePublished\":\"2019-11-30T08:00:46+00:00\",\"dateModified\":\"2022-04-14T06:10:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\"},\"wordCount\":3570,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\",\"keywords\":[\"C Programming\"],\"articleSection\":[\"C Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\",\"name\":\"C Programming Interview Questions | Prepbytes |\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\",\"datePublished\":\"2019-11-30T08:00:46+00:00\",\"dateModified\":\"2022-04-14T06:10:53+00:00\",\"description\":\"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C Programming\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/c-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Top 50 C Programming Interview Questions and Answers\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e\",\"name\":\"PrepBytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g\",\"caption\":\"PrepBytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C Programming Interview Questions | Prepbytes |","description":"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/","og_locale":"en_US","og_type":"article","og_title":"C Programming Interview Questions | Prepbytes |","og_description":"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.","og_url":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2019-11-30T08:00:46+00:00","article_modified_time":"2022-04-14T06:10:53+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png","type":"","width":"","height":""}],"author":"PrepBytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PrepBytes","Est. reading time":"22 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/"},"author":{"name":"PrepBytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e"},"headline":"Top 50 C Programming Interview Questions and Answers","datePublished":"2019-11-30T08:00:46+00:00","dateModified":"2022-04-14T06:10:53+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/"},"wordCount":3570,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png","keywords":["C Programming"],"articleSection":["C Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/","url":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/","name":"C Programming Interview Questions | Prepbytes |","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png","datePublished":"2019-11-30T08:00:46+00:00","dateModified":"2022-04-14T06:10:53+00:00","description":"How will you print \u201cHello World\u201d without using semicolon even once in your code.printf() function will print \u201cHello World\u201d to the console.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1645528366106-B_447-C-Top-50.png"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/top-50-c-programming-interview-questions-and-answers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"C Programming","item":"https:\/\/prepbytes.com\/blog\/category\/c-programming\/"},{"@type":"ListItem","position":3,"name":"Top 50 C Programming Interview Questions and Answers"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/39fcf072e04987f16796546f2ca83c2e","name":"PrepBytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/850669d326db1e1531f04db0c63145d941c2a26792aaeee226a9e6675b0ac698?s=96&d=mm&r=g","caption":"PrepBytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/prepbytes\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=208"}],"version-history":[{"count":6,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":8469,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/208\/revisions\/8469"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}