UrbanPro
true

Take BTech Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Some interview questions for freshers on C language

Shiladitya Munshi
25/11/2016 0 0
Q1. What are the two forms of #include?
 
There are two variants of #include. The one is #include and the other one is #include”file”. In general the first form that is #include is used to include system defined header files which are searched in the standard list of system directories. The second form i,e #include”file” is generally used to include user defined header files. These files are searched first in the current directory , if failed, then secondly in the standard list of system directories.
Both the forms of #include share a common property that is no escape sequence or commenting styles are recognized within or “file”. What I mean to say is that if I write #include <x/*y>, that means I want to include a file named x/*y.  Similarly writing #include<x\y\\z> is also perfect if the file x\y\\z is needed to be included.
   
Q2. What is the difference between Function and Subroutine?
 
The difference is indeed very thin and it depends on the context. In general Function is a piece of code with a name, inputs (arguments) and an output (return types). That is function should always return. Some programming languages are there which uniquely maps inputs to the corresponding outputs. But surely C is not such.  There is also a convention (but not a very strict one) that a function should not change any global variable. In C language, a function is always a realistic part of the code.
Subroutine is just a piece of any sorts of code with a definite entry and exit point. It should not return anything and a subroutine can always change global variables. These are generally used for conceptual purposes like in psudocodes.
 
Q3. What are register variables?
 
Registers are faster than memories to access. Hence when we declare a variable with a registerkey word, the compiler gets to know that the variable can be put to registers. Now whether the variables will be put into the register indeed or not, that depends on the compiler and the number and size of the registers for the corresponding hardware.
In general, the variables which are to be used with high frequencies (like loop variables) are the perfect choice for declaring as register, because the gain in speed would be considerable in those cases.
It is not allowed to access the address of the register variables as accessing the address of the register is illegal.
It is perfectly all right to declare a pointer as register because a register can always store the address of other variables if the size of the register permits that to do.
 
Q4. What is the difference between Scope and Lifetime?
 
Scope of a variable is defined as the block of code from where we can refer or access it. On the other hand the life time of a variable is defined as the time in between allocating memory for it and relinquishing the memory from it.  Let us have an example
 
void func1(void){
int x = 5;
// do other stuffs
}
void func2(void){
int y = 10;
func1();
//do other stuffs
}
 
In the above example scope of x is func1 and scope of y is func2. Now when we call func1 from func2, then inside func1, scope of y is ended but the life time of y still persists,  because the memory for y is still not relinquished.
 
Q5. What is your thoughts on the memory model of C with respect to the storage classes?
 
The entire memory (with respect to C program) can be divided into four logical segments. Data, Stack, Code and Heap.  The Code area contains all the instructions of the current program code. Data contains the Static and Extern variables. Auto variables are stored in Stack. The Heap area will be occupied by dynamically allocated variables. Lastly the Register variables will find its place CPU registers.  
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

C++ Program-Working with constant using #define preprocessor
//Header Files #include#include // using #define preprocessor for defining a constant#define len 10#define br 5#define rad 3#define NEWLINE '\n' //Main function void main(){ int area_r; float area_c; //Function...
S

What is a Programming Language
What is a Language? Language is a communication system of human. What is a programming Language? A programming Language is a formal constructed language design to communicate...

Electrical & Electronics Engineer
Electrical students should have knowledge of Matlab , Pspice , & circuit simulation. C & C++ is an added advantage. They should also learn PCB Circuit Designing
U

Utpal Kant

0 0
0

Understanding Big Omega (?), Big Theta (?), Small Oh (o) And Small Omega (?) Notations
How to describe Big Omega(Ω) ? If run time of an algorithm is of Ω(g(n)), it means that the running time of the algorithm (as n gets larger) is at least proportional to g(n). Hence it helps...

Finding a Majority Element
Problem Description Task. The goal in this code problem is to check whether an input sequence contains a majority element. Input Format. The first line contains an integer, the next one contains a sequence...
X

Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more