Sunday 12 March 2017

Hello friends comment which topic you need 

Saturday 9 April 2016

C INTERVIEW QUESTIONS ON FUNCTIONS CONCEPT

1. What is a function?
Ans:
A function is a set of instructions, which performs a specific task when it is called.

eg: printf() --> Performs the task of printing something on the screen
scanf() --> Performs the task of reading something from the keyboard
exit() --> exits the program
rand() --> returns a random number
strcmp() --> compares two strings and returns a value
bubbleSort() ( userdefined ) -> sorts an integer array
binarySearch() ( userdefined ) --> searches for an elements using binary search algorithm
push() ( userdefined)--> pushes an element into a stack  etc

2. What is the benefit of writing a piece of code as a separate function?
Ans:a)Avoids code repetition.
b)modular programming can be achieved.
c)easy to debug.

3. When does the control return from a function
Ans:
There are two cases:
a) When the control reaches to the end of the function i.e., closing brace of the function.
b) When a return statement gets executed.

4. How many values can be returned from a function?
Ans:
Only one value directly. However, indirectly any number of values can be returned from a function.

5. What is a function prototype, why is it required?
Ans:
A function’s prototype contains:

Its Name
Its Parameters list
Its Return type

6. What is the advantage of dividing a program into separate files?
Ans:
Better organization.  Suppose that different files contain different set of functions. Suppose that a set of functions from a file is required in some other program. It is sufficient to just include that file in a required file.

7. What is the default return type of a function?
Ans:
Integer

8. From where can a function be called?
Ans:
Local Vs STD Vs ISD

Local : Recursion
STD    Same file
ISD         : External file

9. What is the best place for function prototype?
Ans:
At the top of a program outside all the functions so that it can be called from any function in any file

10. What happens when we return a value from a function whose return type is void?
Ans:
Error

11. What happens when we don’t return a value from a non-void return type function?
Ans:
Compiler dependent:
Turbo C -> the number of arguments it receives
Turbo C++ --> same
GCC (Linux) --> same
VC++  --> Error

12. What happens when we don’t catch the returned value from a function?
Ans:
Turbo C  --> No problem
Turbo C++  --> same
GCC  --> same
VC++ --> same

13. What are actual arguments/formal arguments/parameters?
Ans:
Actual arguments:

The values which are passed into a function at its calling statement :
The actual argument may be a:
Variable  Eg: fun(a)
Constant  Eg: fun(10 )
Expression Eg: fun (a+b, c, d*e)
Address  Eg: fun (&a)

Formal arguments/ parameters

The variables in the parameters list section of a function’s body

14.What is the advantage of unformatted console I/O functions?
Ans:
They are more efficient when compared to equivalent formatted counterparts because:

They do not have the overhead of formatting the input or output.

Formatted I/O functions unformatted I/O functions

printf(“%d\n%.2f\nHello – %-20s”, ….), puts()
scanf(“%[ ^\n]”, ….) gets()
scanf(“%20s”, …) getchar()

15. What are the different storage classes in C ?
Ans:There are four types of storage classes in C. They are extern, register, auto and static

16. What does static variable mean?
Ans:Static is an access qualifier. If a variable is declared as static inside a function, the scope is limited to the function,but it will exists for the life time of the program. Values will be persisted between successive
calls to a function

17. What is scope of a variable?
Ans:The area or the part in which a variable is accessible.

18. What is the purpose of register storage class?
Ans:Execution speed may increase

19. What is recursion ?
Ans:Recursion : calling a function from itself is called as recursion.

20. Difference between pass by reference and pass by value?
Ans:Pass by value just passes the value from caller to calling function so the called function cannot modify the values in caller function. But Pass by reference will pass the address to the caller function instead of value if called function requires to modify any value it can directly modify.

Friday 8 April 2016

C LANGUAGE INTERVIEW QUESTIONS ON ARRAYS COCEPT

1. What is an Array?
Ans:An array is a collection of similar type of elements stored in adjacent locations

2. What is a Dimension?
Ans:
It tells us the maximum number of indexes that can be used to represent an element of an array
for 1-D ( only 1)
For 2-D ( only 2)

3. What is the difference between an array and a string?
Ans: An array is a collection of similar type of elements stored in adjacent locations.
A character array or  a string is a collection of characters terminated by a null character.

4. How to read multiple word strings?
Ans: Method 1 : scanf(“%[^\n]”, st);
Method 2 : gets( st );

5. What is the advantage of arrays?
Ans:
A set of elements can be accessed very easily using loops
Sorting of a set of elements
Generating results sheet of a set of students storing their marks & roll numbers in arrays
Processing of matrices
Processing of tabular data

6.When to use 2-D arrays?
Ans:
Whenever we need to arrange any data in the form of rows and columns – then we use 2-D arrays
Eg: Matrix multiplication
Puzzle Game
Calender generation

7. What is row major style/column major style of 2-D array arrangement?
Ans:
Row major style
Here the elements of a 2-D array are arranged row after row in the memory
Column major style
Here the elements of a 2-D array are arranged column after column in the memory


8. If we initialize a 2-D array, why column size is compulsory?
Ans:
Only then, the compiler knows how many elements should be kept in a row.

9. What are the different styles of initializing a 2-D array?
Ans:
method1:

int a[][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};

1 2 3  4 5 6  7 8 9  10 11 12  13 14 0 
method 2 :

int a[][3] = {  {1, 2 }, {4, 8, 13}, { 7, 76, 43}, {9, 17} };

1 2 0  4 8 13  7 76 43  9 17 0 

10. How to declare an array?
Ans: <datatype> arrayname[size];

11. What are the characteristics of an array?
Ans: a)All the elements are of same data type.
b) All the elements will be stored in continuous memory locations.
c) The size should be a positive integer.

Thursday 7 April 2016

C LANGUAGE INTERVIEW QUESTIONS ON CONTROL STATEMENTS

1. What are Control structures?
Ans:  These are the programming statements, which controls the sequence of program execution.
Some statements are executed based on conditions.
Some statements gets executed repeated number of times.

2. When do we use goto statement?
Ans: To terminate a deeply nested looping structure
If a condition is satisfied then go up & execute a statement
( raindrops eg – for random colors – to skip black color )

up:

rnd = random( 16 );

if( rnd  == 0 )
goto up;

textcolor( rnd );

3. If a semicolon is put at the end of [for, if, else, while etc]. Explain the results?
Ans:
Semicolon at the end of for loop
for(I=1;I<=10;I++);
printf(“%d\n”, I);

output : 11

Semicolon at the end of while loop
I = 1;
while( I <= 10 );
{
printf(“%d”, I);
}

output :  Program runs for infinite times without printing anything

Semicolon at the end of if condition
Case I:

if (n > 10);
printf(“Hai\n”);
else
printf(“Bye”);

Error : hanging else

Case II:

if( n > 10 );
printf(“Hai\n”);

printf(“Bye”);

Output:
If n is > 10 then
Hai

If n <= 10 then output would be:
Hai
Bye

Semicolon at the end of else
if(n > 10 )
printf(“Hai”);
else;
printf(“Bye”);

Output: Bye would be printed always, The printed of Hai depends on the condition

4. When to use what loop?
Ans:
For loop:
If we have all the three sections directly (initialization; testing; modification)
Ex1 : for( I = 1; I<=n;I++)
Also these sections should be small statements
If modification should take place at the end
If we know in advance the number of times the loop should run.

While loop:
If we don’t have all the three sections directly
ex1: reverse a number  while( n )
Ex: n = n/10;
Also if modification is in the middle of the loop block.
Ex: raindrops program
If we don’t know in advance, the number of times a loop should run.
Do- while loop

Same as that of while loop, except that it runs at least once.

6.  Is it necessary to define a label with every goto statement? Justify your statement?
Ans: Yes. Otherwise how can it know where to transfer the control.

C LANGUAGE INTERVIEW QUESTIONS - INTRODUCTION

1. What is a Program?
Ans: set of instructions passed to a computer that tells it to do some task.

2. What are the basic steps before executing a program (by the programmer) written by the same programmer)
Ans: a)Algorithm/logic/plan preparation
b)Coding
c)Transformation (Compilation/ Interpretation)(conversion of high level language to low level).
d)Execution

3. What is a programming language?
Ans: It is a medium of communication between user and the computer.Used for writing programs.

4. What is a Syntax?
Ans : The set of rules that govern the writing of a particular statement in a particular programming language.

5. What is a Symantic?
Ans : The meaning of a syntax

6. Define efficiency of a Program
Ans: A program is said to be efficient if it runs with maximum speed and uses minimum memory(resources).

7.Features of LLL Vs HLL
Ans:
LLL
HLL
Platform dependent
platform independent (not tied to any one h/w architec.)
Program development is slow
faster
Runs efficiently
less efficiently


8. What is meant by System software and Application software?
Ans: System software:The software used to run and maintain the system.eg:Operating system.
Application software:The software used to perform a specific task.eg:M word,excel,ppt etc.

9. What is a statement?
Ans: Any expression, including an assignment or a function call can be a statement.

10. Differentiate Compilation & Interpretation
Ans: Compilation :Converting entire source program into object code at a time.
 Interpretation:Converts the source program into object code line by line.

11. What is Structured Programming?
Ans: A program, which consists of:
a)Sequence
b)Decision
c)Looping

12. What is an Assembly Code?
Ans: Symbolic representation of machine code instructions.
Eg: MOV, PUSH, POP, ADD, SUB, MUL, DIV, LOOP, RET, CALL, SUB etc.

14. When is low-level programming used?
Ans:Low-level programming is typically used only for very small programs (because it is a very slow process),
or for segments of code that are highly critical and must run as efficiently as possible.

15.  What is C?
Ans:
a)It is a Middle level programming language.It combines both the features of low level and high level.
b)It is derived from BCPL and B.
c)Invented by Dennis Ritche in 1972 at AT &T bell's.

16.  Explain the necessity of learning C (Why anyone can learn C)?
Ans:It is a userfriendly language.It is the basic language for any other programming languages.It is very simple.

17. Name some popular software developed using C?
Ans: Unix, Windows, Linux, Solaris, Macintosh, IBM OS/400 etc Operating Systems
Desktop Computer Games

18. Mention different types of errors in C?
Ans: a)Compile time(Syntax) errors.eg: missing semicolon, improper “ and {
b)Runtime errors.eg:division by zero.
c)Data errors
d)Logical errors

19. What does linking mean?
Ans: It  provides instructions to the compiler to link required functions from the system library.
eg:It informs compiler to link printf(),scanf() functions from standard library stdio.

20. What is typecasting?
Ans:Temporary conversion of a variable from one type into another type
Eg : c = (float) a / b;

21.What are the characteristics of C?
Ans: a) Every c program requires a main() function from where the execution start.
b) c programs are written in lowercase letters.
c) Every executable statement in c should terminate with a semicolon.
d) c is a free form language(we can write any number of statements in one line separated with semicolon).

22. In header files weather the functions are declared or defined?
Ans:declared.

23. What are the types of constants in c?
Ans: 1. Numeric constants
1.1.Integer constants
1.2.real or floating point constants
2. Character constants
2.1.single character constants
2.2.string constants

24. What is the use of typedef and enumerations?
Ans: typedef and enum are user defined datatypes.
Used to create a new datatype name for an existing datatype.
eg:  typedef longint s;
s a,b,c;
enumerations used to declare variables that store list of names.

enum days {sun,mon,tue,wed,......};
days a1,a2,a3;

25. Difference between pre increment and post increment?
Ans:Pre increment:It first increments the value of the variable next it will assign the value to the left hand side variable.
post increment:It first assigns the value to the variable on the left hand side and then increments the value.
eg: a=5; a=5
b=++a; b=a++;
here b=6 a=6 here b=5 a=6