C language interview questions solution for freshers beginners placement tricky good pointers answers explanation operators data types arrays structures functions recursion preprocessors looping file handling strings switch case if else printf advance linux objective mcq faq online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c++ tutorials and pdf
Data types interview questions and
answers with explanation
Note: As you know size of data types is compiler dependent in c. Answer of all question is based upon that compilers whose word size is two byte. Just to know you, size of data type in 2 bytes compilers is as follow:
Really thanks 4 providing such a huge range of beyond imagination quests.. Thanks a lot... @Admin: jz an advice for options of answers use radiobutton group instead.. because multiple answers are getting selected of same quest and they arent getting unchecked also..
hey anonymous i googled n got the answer for ur above question.. here it is....
Cyclic nature of data type in C In C some data types shows one special properties that when we assign a value beyond range of that data type then it will not any compiler error but assign a number according to some cyclic order. This property is known as cyclic nature of data type. Data type which shows cyclic nature: (a) char (b) int (c) long int Data type which doesn’t show cyclic nature: (a) float (b) double (c) long double
1. Cyclic nature of unsigned char: Range of unsigned char is 0 to 255. If we will assign a value greater than 255 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than 0 then move in anti clockwise direction.
Short cut formula to find cyclic value: If number is X where X is greater than 255 then New value = X % 256 If number is Y where Y is less than 0 then New value = 256 – (Y% 256)
2. Cyclic nature of signed char:
Range of unsigned char is -128 to 127. If we will assign a value greater than 127 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than -128 then move in anti clockwise direction.
Short cut formula to find cyclic value: If number is X where X is greater than 127 then p = X % 256 if p <=127 New value = p else New value = p – 256 If number is Y where Y is less than -128 then p = Y % 256 If p <= 127 New value = -p else New value = 256 -p
what is the output of this program....and also explain it..how the answer it comes main() { int a, b, c; a = 10; b = 20; c = printf("%d",a) + ++b; printf ("%d",c); }
here the reason is real numbers are stored in IEEE 754 format so the bit fields for float fills out to be 32 bit ie..a where as the bit fields for 0.7 which by default acts as double which is of 64 bits when you try to compare a will be lesser than 0.7 because the a is type casted implicitly which implicitly becomes 8 bytes .for further details look at memory representation of real numbers.
why because char constant consider a int so what it showing 4 bytes for example the capital value of A equivalent int value is 65(int) if u going to print both is same printf(sizeof('A'));
11. What will be output when you will execute following c code?
#include int main(){ volatile int a=11; printf("%d",a); return 0; }
i have executed this code on GCC compiler and i am getting the output as 11. but in the explanation of this code it is written that compiler can not predict the volatile variable.. why it is so ... please clear my doubt.
define array. How will you do the following?: 1. declare array 2. Initialize array 3. Enter data in array 4. Access elements of an array 5. Get output from an array. --- - -- - and - --- - - Write a program to add two 3*3 matrix using array.
55 comments:
nice
thanks itz really good
Really thanks 4 providing such a huge range of beyond imagination quests.. Thanks a lot...
@Admin: jz an advice for options of answers use radiobutton group instead.. because multiple answers are getting selected of same quest and they arent getting unchecked also..
for question 1 output is 8 4 1.
can u provide solution to que:4
How i present 0123 as integer variable.
Marvelous...Very useful to me....My grateful thanks to you......................
hey where can i find a pdf of all these questions ?
its very useful to me,,,,,,,,,,,,,,,,thanks
Plz Clear Question No.14 because what is -6. signed char range is 0 to -128 to 127
hey anonymous i googled n got the answer for ur above question.. here it is....
Cyclic nature of data type in C
In C some data types shows one special properties that when we assign a value beyond range of that data type then it will not any compiler error but assign a number according to some cyclic order. This property is known as cyclic nature of data type.
Data type which shows cyclic nature:
(a) char
(b) int
(c) long int
Data type which doesn’t show cyclic nature:
(a) float
(b) double
(c) long double
1. Cyclic nature of unsigned char:
Range of unsigned char is 0 to 255. If we will assign a value greater than 255 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than 0 then move in anti clockwise direction.
Short cut formula to find cyclic value:
If number is X where X is greater than 255 then
New value = X % 256
If number is Y where Y is less than 0 then
New value = 256 – (Y% 256)
2. Cyclic nature of signed char:
Range of unsigned char is -128 to 127. If we will assign a value greater than 127 then value of variable will be changed to a value if we will move clockwise direction as shown in the figure according to number. If number is less than -128 then move in anti clockwise direction.
Short cut formula to find cyclic value:
If number is X where X is greater than 127 then
p = X % 256
if p <=127
New value = p
else
New value = p – 256
If number is Y where Y is less than -128 then
p = Y % 256
If p <= 127
New value = -p
else
New value = 256 -p
My name Ayesha
I hope this link will help you.
Cyclic nature of data types
very nice
you can test your c skills
where did you get int's size is 2, it is 4 byte.
very nice
this test is amesign cncept
nice exercises!! learned a lot of new things!!
nice really.. njoy it...
Can anyone explain the output of program as under:
#include
int array[]={1,2,3,4,5,6,7,8};
#define SIZE (sizeof(array)/sizeof(int))
main()
{
if(-1<=SIZE) printf("1");
else printf("2");
}
what is the output of this program....and also explain it..how the answer it comes
main()
{
int a, b, c;
a = 10;
b = 20;
c = printf("%d",a) + ++b;
printf ("%d",c);
}
i think the output will be 31..because here we used pre increment operation for b
i.e.,10+21=31.
or else the output will be 1023
2
#include
#include
void main()
{
float a=0.7;
if(a<0.7)
printf("stoned");
else
printf("Avenged");
}
plz reply what is the ans
here the reason is real numbers are stored in IEEE 754 format so the bit fields for float fills out to be 32 bit ie..a
where as the bit fields for 0.7 which by default acts as double which is of 64 bits when you try to compare a will be lesser than 0.7 because the a is type casted implicitly which implicitly becomes 8 bytes .for further details look at memory representation of real numbers.
2+21=23
because printf("%d",a) results 2 because a= 10 has two digits ..
Explain how its output is 1023
bro how you created this quizz and can you tell me which site u used to create this quiz :)
good knowledge of quiz thanks..
the solution is 8 4 2
please explane me this the output is 1 7
#include
int x = 0;
int main()
{
int i = (f() + g()) | g(); //bitwise or
int j = g() | (f() + g()); //bitwise or
printf("%d",i);
printf("%d",j);
}
int f()
{
if (x == 0)
return x + 1;
else
return x - 1;
}
int g()
{
return x++;
}
why is 8 4 2? more precisely why is ..2 instead 1(char : 1 byte)
why because char constant consider a int so what it showing 4 bytes for example the capital value of A equivalent int value is 65(int) if u going to print both is same
printf(sizeof('A'));
printf(sizeof(65));
very useful for all beginers
in tubo c int's size is 2
11.
What will be output when you will execute following c code?
#include
int main(){
volatile int a=11;
printf("%d",a);
return 0;
}
i have executed this code on GCC compiler and i am getting the output as 11.
but in the explanation of this code it is written that compiler can not predict the volatile variable.. why it is so ... please clear my doubt.
What are the various stage of programming development ?
Explain different tools for program logic development.
Why are flow-charts used? Explain symbols for making a flow chart-charts?
What are main programming characteristics?
What are various methods of compiling a C program?
Write a C program to find the largest of three numbers.
Write a note on operator in C.
what are statement different types in C? Explain all three iterative statement with syntax.
define array. How will you do the following?:
1. declare array
2. Initialize array
3. Enter data in array
4. Access elements of an array
5. Get output from an array.
--- - -- - and - --- - -
Write a program to add two 3*3 matrix using array.
best question of c language:-
Question:- Define function. What are advantage of using functions? how are functions.
8 4 2 is the output
main can be written as var name
thanks for this question
in qstn no 13 how we get z=y+1 ??
write a program that input two number and finds if second number is square of 1st number
please solve this program plz
write a program that input two number and finds if second number is square of 1st number
please solve this program plz
awesome
Great post
Gud post,please add data structure mcq type questions n answer.
Post a Comment