Featured post

Math : Diffusion Equation or Heat Equation

Diffusion equation at finite rod, Semi-infinite rod and infinite rod have been discussed. Thank you. Feel free to comment.

8/12/2019

8/10/2019

Ugc to university

hupdated the recruitment of faculty in universities, colleges and institutions deemed to be universities. Earlier a letter was issued about the application process on July 31, 2019. All the universities and its affiliated colleges were requested to upload the details of all the vacant posts, along with the reservations and advertisement details on the online portal http://nherc.in.e University Grant Commission, UGC, has

8/08/2019

C programming question in interview

1) What are the key features of C programming language?


C is a platform-dependent language.


C offers the possibility to break down a large program into small modules.


Also, the possibility of a programmer to control the language.


C comes with support for system programming and hence it compiles and executes with high speed when compared to other high-level languages.


2) What happens when you compile a program in C? (tricky question)

Whenever you compile a program in C, a multi-stage process takes places. The process is as shown below. Click here to know the complete process & function of compiler, assembles, linker and loader in this process.

3) What is the use of header files in C?

Header files contain the definitions and set of rules of the functions being used in the programs.

For example, when you use printf() or scanf() in your program, you nee to include stdio.h library function. Else your compiler will show an error. This is because, the standard input and output functions printf() and scanf() are stored in this header file.

So similarly every header file stores a set of predefined functions which makes it easy to program.

4) What happens if a headerfile is included twice? (tricky question)

When the preprocessor sees a #include, it replaces the #include with the contents of the specified header. By using include guard(#), you can prevent a header file from being included multiple times during the compilation process. So basically, if a header file with proper syntax is included twice, the second one gets ignored.

5) Can a program be compiled without the main() function?

Yes, compilation is possible, but the execution is not possible. However, if you use #define, we can execute the program without the need of main().

For Example:

#include<stdio.h>    
#define start main    
void begin() {    
   printf("Hi");    
}

C Programming Interview Questions on Data Types, Variables & keywords

6) What are the basic data types in C?

Int – Used to represent a number (integer)


Float – Used to represent a decimal number


Double – Used to represent a decimal number with highest precision(digits after the decimal point)


Char – Single character


Void – Special purpose type without any value


7) Is it possible to store 32768 in an int data type variable? (Tricky question)

Int data type is capable of storing values between – 32768 to 32767. To store 32768 a modifier has to be used with int data type and hence Long Int can be used. If there are no negative values, unsigned int can also be used.

8) What are the various Keywords used in C?

There are 32 various keywords in C and each of them performs a defined function. These keywords are also called as Reserved words. Click here to know the functions of the below keywords.

9) What is the difference between static & global variables?

Global variables are variables which are defined outside the function. The scope of global variables begins at the point where they are defined and lasts till the end of the file/program. Whereas, static global variables are private to the source file where they are defined and do not conflict with other variables in other source files which would have the same name.

10) What is Memory Leak in C?

A memory leak occurs when programmers create a memory in the heap and forget to delete it. It decreases the efficiency of the performance of the system.

11) What is Static and Dynamic memory allocation?

Static memory allocation happens atcompile-time, and memory can’t be increased while executing the program. 


Whereas in case of dynamic memory allocation, this happens at runtime and memory can be increased while executing the program. 


Static memory allocation is used in arrays& dynamic memory allocation is used in Linked Lists.


Static memory allocation uses more memory space to store a variable.


 

C Programming Interview Questions on Operators, Input/output

12) What is the difference between ++a and a++?

‘++a’ is called prefix increment. First, the value stored in the variable ‘a’ gets incremented and then gets assigned to the same variable.  Whereas, ‘a++’ is called postfix increment. The value stored in the variable ‘a’ gets incremented after the execution of the particular line.

13) What is the difference between while (0) and while (1)?

While(1) is an infinite loop which will run till a break statement occurs. Similarly, while(2), while(3), while(255) etc will all give infinite loops only.

Whereas, While(0) does the exact opposite of this. When while(0) is used, it means the conditions will always be false. Thus, as a result, the program will never get executed. 

 

C Programming Interview Questions on Arrays, Strings, Pointers & Functions

14) What is a Dangling Pointer in C?

A pointer pointing to a dereferenced memory location is called dangling pointer. i.e. pointer pointing to the memory location which is deleted. There are three different ways where a pointer can act as a dangling pointer.

De-allocation of memory


When the local variable is not static


When the variable goes out of scope


To understand in detail, check this – Dangling pointer in c with examples

15) What is the difference between the Void and Null Pointer?

Null pointers generally do not point to a valid location.  A pointer is initialized as NULL if we are not aware of its value at the time of declaration. 

Whereas, Void pointers are general-purpose pointers which do not have any type associated with them and can contain the address of any type of variable. So basically, the type of data that it points to can be anything. 

>> Check out the detailed difference between null and void pointers.

16) What is the difference between Pass by value and Pass by reference?

In pass by value, changes made to the arguments in the called function will not be reflected in the calling function. Whereas in pass by reference, the changes made to the arguments in the called function will be reflected in the calling function. 

The below image will help you get a good understanding, however, click here to know the difference between Pass by value and Pass by reference in detail.

17) What is a pointer on a pointer in C programming language?

A pointer variable that contains the address of another pointer variable is called as a pointer on a pointer. For example, consider the following program.

int main()
{
    int v1 = 54;  
    int *pointer2; // pointer for var
    int **pointer1; // double pointer for ptr2
    pointer2 = &v1; // storing address of var in ptr2   
    pointer1 = &pointer2; // Storing address of ptr2 in ptr1     
    printf("Value of v1 = %d\n", v1);
    printf("Value of v1 using single pointer = %d\n", *pointer2 );
    printf("Value of v1 using double pointer = %d\n", **pointer1);
  return 0;
} 

18) Difference between malloc() and calloc() functions?

malloc and calloc are library functions that allocate memory dynamically, which means that memory is allocated during the runtimefrom the heap segment.

Malloc and Calloc differ in the number of arguments used, their initialization methods and also in the return values. Check out the detailed differences here.

19) What is the difference between Arrays and Pointers?

A few differences between Arrays and Pointers are:

An array is a collection of elements of similar data type whereas the pointer is a variable that stores the address of another variable. 


An array size decides the number of variables it can store whereas; a pointer variable can store the address of only one variable in it.


Arrays can be initialized at the definition, while pointers cannot be initialized at the definition.


>> Click here to know more differences

20) What is the difference between a structure and a Union?

All the members of a structure can be accessed simultaneously but union can access only one member at a time


Altering the value of a member will not affect the other members of the structure but where it affects the members of a union


Lesser memory is needed for a union variable than a structure variable of the same type


>> More details

 

C Interview Programs with Solutions

21) Write a program to print “hello world” without using a semicolon?

#include <stdio.h>      
void main()
{      
 if(printf("hello world"))
{
}}    

22) How to swap two numbers without the use of the third variable?

#include<stdio.h>          
main()      
{      
int a=1, b=8;  
printf("Before swapping a=%d b=%d",a,b);a=a+b;//a=30        
b=a-b;//b=10      
a=a-b;//a=20         
printf("After swapping a=%d b=%d",a,b); 
getch();      
}  

23) Program to reverse a given number in C

24) Program to print factorial of a number

25) Print Fibonacci series up to n 

26) Print all the prime numbers in a given range

27) Check if a given number is an Armstrong number or not.

28) Replace all 0’s with 1 in a given integer.

29) Pyramid pattern using stars

*
* *
* * *
* * * * 
* * * * *
* * * * * *           *
        *   *
      *   *   *
    *   *   *   *
  *   *   *   *   *
*   *   *   *   *   *

30) Reverse a string using recursion

Practice more C programming questions

Some videos on C Programming Interview Questions

Practice C, C++ and Java programming


Practice DS & Algorithms


C programming concepts


Data Structures & Algorithms concepts


C++ programming concepts


Java programming concepts


C Programming Interview Questions


Solved HackerRank Questions


For quick tips on programming, subscribe to our youtube channel. Click here to subscribe now

MOST VIEWED ARTICLES OF 2019

 

 Discussion Forum


 Home


 Courses


 Learning Centerexpand child menu


My Accountexpand child menu

8/07/2019

CSIR NET 2018 JUNE CUT-OFF


CSIR NET 2018 JUNE CUT OFF

csir cutoff 2018 dec

Minimum cut-off percentage for the award of fellowship/lectureship in different disciplines in the Joint CSIR-UGC test for Junior Research Fellowship & Eligibility for Lectureship held on 16th December, 2018 Junior Research Fellowship (NET) Lectureship (NET)

Subject          UNRESERVED OBC     SC         ST          PwD      UNRESERVED OBC SC ST PwD
Chemical Science 57.75 %     49.75 % 40.25 % 30.25 % 25.50 %  51.98 % 44.78 % 36.23 % 27.23 % 25.00 %
Earth Science 52.54 % 45.99 % 39.74 % 37.99 % 25.68 % 47.29 % 41.39 % 35.77 % 34.19 % 25.00 % Life Science 59.25 % 50.50 % 42.75 % 37.75 % 26.00 % 53.33 % 45.45 % 38.48 % 33.98 % 25.00 % Mathematical Science 48.63 % 41.00 % 31.88 % 25.25 % 25.00 % 43.77 % 36.90 % 28.69 % 25.00 % 25.00 %
Physical Science 53.31 % 45.88 % 37.19 % 29.19 % 25.00 % 47.98 % 41.29 % 33.47 % 26.27 % 25.00 %
 Kindly Note: There is no separate cut-off for Part A, B & C. The cumulative marks of all parts are taken into consideration for drawing of merit list. The date of declaration of Joint CSIR-UGC Junior Research Fellowship & Eligibility for Lectureship (NET) Exam held on 16th December, 2018 is 02/04/2019. Candidates with Bachelor’s Degree are eligible for Fellowship only as per the Clause 5 of our Notification. Ranks are allotted first to all successful candidates qualifying for Junior Research Fellowship as per the merit list of JRF and then the candidates are distributed between CSIR and UGC in the ratio of number of fellowships shared between these two for each subject except Bachelor’s degree holder’s who are allocated to CSIR. There is a minimum bench mark of 33 % for General & OBC category and 25 % in respect of SC/ST and PwD categories for both fellowship and lectureship. CSIR HRDG is not responsible for any inadvertent error that may have crept in the result being published on internet. 

7/25/2019

BTSC Bihar recruitment teacher and nurse 2019

BTSC Bihar Jobs 2019: Bihar Technical Service Commission (BTSC) has issued a latest recruitment notification for hiring huge number of employees for the post of Tutor in Nursing Schools and for the post of Staff Nurse Grade ‘A’. A total of 9299 vacancies have been notified out of which 9130 are for Staff Nurse and 169 for Tutor Posts. BTSC recruitment will be done through Online Mode only.


BTSC Online Application process will start from 24 July 2019. Eligible and interested candidates can apply for BTSC Nurse and BTSC Teacher Posts through official website www.btsc.bih.nic.in on or before 26 August 2019.


Candidates are required to pay Rs. 200 (Rs. 50 for SC/ ST/ EBC/ Women Candidates) as an application fee


Other details of Bihar Technical Service Commission Recruitment 2019 like Educational Qualification, Age Limit, Application process etc. are given below in this article.


Important Dates


Starting Date of Online Application - 24 July 2019


Last Date of Online Application - 26 August 2019


BTSC Bihar Vacancy Details


Staff Nurse Grade ‘A’– 9130 Posts


Tutor – 169 Posts


Pay Scale:


Staff Nurse - Level-7, 7th CPC Grade Pay Rs. 4600


Tutor - Level-8, 7th CPC Grade Pay Rs. 4800


Eligibility Criteria for Tutor/Teacher and Staff Nurse Posts


Educational Qualification and Experience:


Staff Nurse Grade ‘A’– Training course in GNM and certificate. The candidate should remain in the jurisdiction of Bihar Nurse Registration Council, Patna.


Tutor – M.Sc. Nursing or B.Sc. Nursing (Basic/ Post Basic) Course or Diploma in Nursing Education and Administration (DNEA) with 02 years work experience


Age Limit:


21 to 37 Years


For more information, check detailed notification given below


Selection Procedure for Tutor/Teacher and Staff Nurse Posts


Selection will be done on the basis of marks in relevant course


How to Apply for BTSC Bihar JE Jobs 2019


The Eligible candidates can apply for the post through the official website (the direct link is given below) from 24 July 2019 to 26 August 2019.