Tolal:206 Click:
1
2 3 4 5 6 7 8 9 10 11
C Interview Questions And Answers
Page 1
Ques: 1 What is C language?
Ans:
programming language
Ans:
C is a middle level programing language. C is a
structured, procedural programming language.c
widely used both for operating systems and
applications.C is also called a system progmming
language
Ans:
The c language is a programming language
Ans:
C is high level language.
Ans:
C is a Structured Oriented Programming Language
Ans:
c is structure programing language.
Ques: 2 What is the output of printf("%d")?
Ans:
0
Ans:
0
Ans:
Any integer value
Ans:
Any integer value
Ans:
the output of this statement depends on data types %d is the data type of int type variabe if you will declare the variable in declaration part suppose u will declare int i so the output of this statement is i...............
Ans:
the output of this statement depends on data types %d is the data type of int type variabe if you will declare the variable in declaration part suppose u will declare int i so the output of this statement is i...............
Ans:
garbegge value
Ans:
garbage integer value
Ans:
Garbage Value
Ques: 3 What is the difference between "calloc(...)" and "malloc(...)"?
Ans:
Some important distance between calloc and malloc are given below:
malloc:
malloc takes only the "size" of the memory block to be allocated as input parameter.
malloc allocates memory as a single contiguous block.
if a single contiguous block cannot be allocated then malloc would fail.
calloc:
calloc takes two parameters: the number of memory blocks and the size of each block of memory
calloc allocates memory which may/may not be contiguous.
all the memory blocks are initialized to 0.
it follows from point 2 that, calloc will not fail if memory can beallocated in non-contiguous blocks when a single contiguous blockcannot be allocated.
Ans:
malloc: malloc create the single block of given size by user
calloc: calloc creates multiple blocks of given size
both return void pointer(void *)so boh requires type casting
malloc: eg:
int *p;
p=(int*)malloc(sizeof(int)*5)
above syntax tells that malloc occupies the 10 bytes memeory and assign the address of first byte to P
calloc: eg:
p=(int*)calloc(5,sizeof(int)*5)
above syntax tells that calloc occupies 5 blocks each of the 10 bytes memeory and assign the address of first byte of first block to P
Ques: 4 What is the difference between "printf(...)" and "sprintf(...)"?
Ans:
the printf() function is supposed to print the output to stdout.In sprintf() function we store the formatted o/p on a string buffer.
Ans:
"printf(....)" is standard output statement
and
"sprintf(......)" is formatted output statement
Ques: 5 How to reduce a final size of executable?
Ans:
Do not include unnecessary header files and
Do not link with unneccesary object files.
Ans:
Use dynamic linking.
Ques: 6 Can you tell me how to check whether a linked list is circular?
Ans:
First you have to Create two pointers, each set to the start of the list. And Update each as below:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next;
if (pointer2)
pointer2=pointer2->next;
if (pointer1 == pointer2) {
print (\"circular\n\");
}
}
Ques: 7 What is the difference between String and Array?
Ans:
Main difference between String and Arrays are:
A string is a specific kind of an array with a well-known convention to determine its length where as An array is an array of anything.
In C, a string is just an array of characters (type char)and always ends with a NULL character. The �value� of an array is the same as the address of (or a pointer to) the
first element; so, frequently, a C string and a pointer to char are used to mean the same thing.
An array can be any length. If it�s passed to a function, there�s no way the function can tell how long the array is supposed to be, unless some convention is used. The convention for strings is NULL termination; the last character is an ASCII NULL character.
Ans:
Array can hold group of element of the same the type, and which allocates the memeory for each element in the array,if we want we can obtain the particular value from an array by giving index value.
Ex: int a[10];
a variable holds the values of integer at max 10.
String can hold any type of data, but it makes together we can't obtain the particular value of the string.
String s="Pra12";
Ques: 8 What is a modulus operator?
Ans:
it gives reminder of any division operation
Ans:
It is an binary arithmetic operator which returns the remainder of division operation. It can used in both floating-point values and integer values.
Use of the modulus operator is given below:
opLeft % opRight
where, opLeft is the left operand and opRight is the right operand. This expression is equivalent to the expression opLeft - ((int) (opLeft / opRight) * opRight)
Ans:
in c language it is used to determine the remainder of any no by deviding the operator if both of them is not float no.
Ans:
it gives remainder part of divisoneg. printf("%d",5%2) output 1
Ques: 9 What are the restrictions of a modulus operator?
Ans:
The modulus operator is denoted in c by symbol %.
we have two integer values x and y and then the operation x % y called as x modulus y gives the result as (x- (x / y) * y).
Say if x=18 and y =5 the x % y gives value as (18- (18 / 5) * 5) which gives (18-15) which results in 3 in other words the remainder of the division operation.
But there is a restriction in C language while using the modulus operator. There are two types of numerical data types namely integers, floats, double. But modulus operator can operator only on integers and cannot operate on floats or double. If anyone tries to use the modulus operator on floats then the compiler would display error message as �Illegal use of Floating Point�.
Ans:
1)modulus operator works as a%b=reminder (sign as reminder is the sign of a). eg: a)3%2=1,
b)3%-2=1,
c)-3%2=-1,
d)-3%-2=-1
in case a only the answer is correct but not in b,c,and d .that's the limitation of modulus operator .
2) it can't works with float and double
Ques: 10 Which one is faster n++ or n+1?Why??
Ans:
The expression n++ requires a single machine instruction. n+1 requires more instructions to carry out this operation.
Ques: 11 What is equivalent expression for x%8?
Ans:
while(x>8)
{
x=x-8;
}
printf("%d",x);
Get the remainder
Ques: 12 Which expression always return true?and Which always return false?
Ans:
Expression are given below;
if (a=0) always return false.
if (a=1) always return true.
Ques: 13 What is Storage class ?
Ans:
There are four type of storage class in C:
1.static
2.auto
3.register
4.extern
Ans:
storage classes in c gives property of the variable,
1.scope of the variable
2.life time
3.memory(either CPU register or memory)
four types of C storage classes,
1.automatic
2.register
3.static
4.extern
Ques: 14 what are storage variable ?
Ans:
A storage class changes the behavior of a variable. It use to controls the lifetime, scope and linkage.
There are five types of storage classes :
1.auto
2.static
3.extern
4.register
5.typedef
Ques: 15 What are the advantages of auto variables?
Ans:
Some main advantages of auto variables are given below:
1.we can use the same auto variable name in different blocks.
2.No side effect by changing the values in the blocks.
3.It used memory economically.
4.Because of local scope auto variables have inherent protection.
Ques: 16 What is auto variables?
Ans:
by default variables are auto.as we know that variable changes its character according to the strage class .
Ans:
Auto variable are the default variables. Static memory allocation will happen
Ques: 17 Diffenentiate between an internal static and external static variable?
Ans:
Some main difference between internal static and external static are given below:
We declare the internal static variable inside a block with static storage class. External static variable is declared outside all the blocks in a file.
In internal static variable has persistent storage,no linkage and block scope, where as in external static variable has permanent storage,internal linkage and file scope.
Ques: 18 What are advantages and disadvantages of external storage class?
Ans:
Some main advantages and disadvantages of external storage class are given below:
advantage:
1.In Persistent storage of a variable retains the updated value.
2.The value is globally available.
Disadvantage:
1. Even we does not need the variable the storage for an external variable exists.
2.Side effect may be produce unexpected output.
3.We can not modify the program easily.
Ques: 19 What are the characteristics of arrays in C?
Ans:
some main characteristics of arrays are given below:
1.all entry in array should have same data type.
2.tables can store values of difference datatypes.
Ques: 20 When does the compiler not implicitly generate the address of the first element of an array?
Ans:
When array name appears in an expression such as:
1.array as an operand of the sizeof operator.
2.array as an operand of & operator.
3.array as a string literal initializer for a character array.
Then the compiler not implicitly generate the address of the first element of an array.
Goto Page:
1
2 3 4 5 6 7 8 9 10 11
C Objective
C Objective Questions And Answers
C Interview Questions And Answers
C Interview Questions And Answers
R4R,C Objective, C Subjective, C Interview Questions And Answers,C,C Interview,C Questions ,C Answers