Download here: http://gg.gg/ob2z5
*Embedded C Programming Interview Questions And Answers Pdf
*Embedded C Programming Interview Questions And Answers Multiple Choice
*Embedded C Programming Interview Questions And Answers 5th
*C Programming Tutorial
*C Programming useful Resources
*Selected Reading
Objective C Interview Questions: Read 20 Best Objective C Interview Questions and answers. Objective C is a computer language that guides in protest arranged programming. While choosing a possibility to deal with this programming language, a few objective C questions are inquired. An embedded system is a computer system that is part of a larger system or machine. It is a system with a dedicated function within a larger e Top 18 Embedded Systems Interview Questions & Answers.
Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is the output of the following code snippet?Answer : AExplanation
A, the range of ASCII values for the ASCII characters is 0-255. Hence the addition operation circulates back to ‘A’
Q 2 - What is the output of the following program?Answer : BExplanation
5 3, call by value mechanism can’t alter actual arguments.
Q 3 - What is the output of the following program?Answer : DExplanation
Compile error, wrong place for ‘break’ to appear.
Q 4 - What is the output of the following program?Answer : AExplanation
stdout is the identifier declared in the header file stdio.h which is connected to standard output device (monitor).
Q 5 - What is the output of the following program?Answer : DExplanation
It’s compile error as the declaration of main() mismatches with the definition.
Q 6 - int fun(); - The declaration indicates the presence of a function defined inside the current module or in the same file.Answer : AExplanation
The function definition can even appear in another source code and can be linked from library while linking.
Q 7 - The given below program allocates the memory, what function will you use to free the allocated memory?Answer : BExplanation
free() is the function in C language to release the allocated memory by any dynamic memory allocating built in library function.
Q 8 - Which of the following is a logical AND operator?Answer : BExplanation
Two immediate ampersand (&) symbols is logical AND operator.
Q 9 - Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers?Answer : AExplanation
Syntax is exp1?exp2:exp3. Any ‘exp’ can be a valid expression.
Q 10 - What will be the output of the given below code?Answer : AExplanation
Although, char str[] = ’Welcome’; and s = str;, the program will print the value of s.Details Last Updated: Tuesday, 10 January 2017 Hits: 55806 Top 60 complex and advanced C Interview Questions and Answers for Experienced programmers covering all aspects of C programming with detailed explanations.
1) What will be the output of printf(“%d”)?The ideal form of printf is printf(’%d’,x); where x is an integer variable. Executing this statement will print the value of x. But here, there is no variable is provided after %d so compiler will show garbage value. The reason is a bit tricky.When access specifiers are used in printf function, the compiler internally uses those specifiers to access the arguments in the argument stack. In ideal scenario compiler determines the variable offset based on the format specifiers provided. If we write printf(’%d’, x) then compiler first accesses the first specifier which is %d and depending on the that the offset of variable x in the memory is calculated. But the printf function takes variable arguments.
The first argument which contains strings to be printed or format specifiers is mandatory. Other than that, the arguments are optional.So, in case of only %d used without any variable in printf, the compiler may generate warning but will not cause any error. In this case, the correct offset based on %d is calculated by compiler but as the actual data variable is not present in that calculated location of memory, the printf will fetch integer size value and print whatever is there (which is garbage value to us).2) What is the return values of printf and scanf?
The printf function upon successful return, returns the number of characters printed in output device. So, printf(“A”) will return 1. The scanf function returns the number of input items successfully matched and assigned, which can be fewer than the format specifiers provided. It can also return zero in case of early matching failure.
3) How to free a block of memory previously allocated without using free?
If the pointer holding that memory address is passed to realloc with size argument as zero (like realloc(ptr, 0)) the the memory will be released.
4) How can you print a string containing ’%’ in printf?
There are no escape sequence provided for ’%’ in C. To print ’%’ one should use ’%%’, like -
5) What is use of %n in printf()?
Ans: According to man page “the number of characters written so far is stored into the integer. indicated by the int * (or variant) pointer argument.“. Meaning if we use it in printf, it will get the number of characters already written until %n is encountered and this number will stored in the variable provided. The variable must be an integer pointer.
Above program will print ’Hello world 5 “ as Hello is 5 letter.
6) Swap two variables without using any control statement ?
We can swap variable using 2 methods. First method is as given below
Second method to swap variables is given below
7) Consider the two structures Struct A and Struct B given below. What will be size of these structures?
struct A{ unsigned char c1 : 3; unsigned char c2 : 4; unsigned char c3 : 1;}a;
struct A{ unsigned char c1 : 3; unsigned char : 0; unsigned char c2 : 4; unsigned char c3 : 1;}a;
The size of the structures will be 1 and 2. In case of first structure, the members will be assigned a byte as follows -76543210c3c2c2c2c2c1c1c1
But in case of second structure -876543210c3c2c2c2c2c1c1c1
The :0 field (0 width bit field) forces the next bit width member assignment to start from the next nibble. By doing so, the c3 variable will be assigned a bit in the next byte, resulting the size of the structure to 2.
8) How to call a function before main()?
To call a function pragma startup directive should be used. Pragma startup can be used like this -
The output of the above program will be -
But this pragma directive is compiler dependent. Gcc does not support this. So, it will ignore the startup directive and will produce no error. But the output in that case will be -
9) What is rvalue and lvalue?
You can think lvalue as a left side operant in an assignment and rvalue is the right. Also, you can remember lavlue as location. So, the lvalue means a location where you can store any value. Say, for statement i = 20, the value 20 is to be stored in the location or address of the variable i. 20 here is rvalue. Then the 20 = I, statement is not valid. It will result in compilation error “lvalue required” as 20 does not represent any location.
10)How to pack a structure?
We can pack any structure using __attribute__((__packed__)) in gcc. Example -
We can also use, pragma pack like this -
In both cases the size of the structure will be 5. But remember, the pragma pack and the other method mentioned, both are compiler dependent.
11) How to convert a string to integer value?
We can convert a string to integer in two ways. Method 1:
Method 2:
12) Print the output of the following switch case program?
Output of this program will be 3. The position of the default is before case 1. So, even if there is no break after case 3, the execution will just exit switch case and it will not go to default case.
13) How to prevent same header file getting included multiple times?
We can use ifndef and define preprocessors. Say the header file is hdrfile.h, then we can write the header file like -
The ifndef will check whether macro HDRFILE_H_ is defined or not. If it is not defined, it will define the macro. From next time onward the statements inside ifndef will not be included.Embedded C Programming Interview Questions And Answers Pdf
14) Which is better #define or enum?
*Enum values can be automatically generated by compiler if we let it. But all the define values are to be mentioned specifically.
*Macro is preprocessor, so unlike enum which is a compile time entity, source code has no idea about these macros. So, the enum is better if we use a debugger to debug the code.
*If we use enum values in a switch and the default case is missing, some compiler will give a warning.
*Enum always makes identifiers of type int. But the macro let us choose between different integral types.
*Macro does not specifically maintain scope restriction unlike enum. For example -
Above program will print -
15) Print the output of this pointer program?Embedded C Programming Interview Questions And Answers Multiple Choice
The program will crash. The pointer p points to string “Pointers”. But the string in constant and C will not allow to change its values. Forcibly doing so, like we did it, will cause crash of the program.Embedded C Programming Interview Questions And Answers 5th
*Prev
*1
Download here: http://gg.gg/ob2z5
https://diarynote.indered.space
*Embedded C Programming Interview Questions And Answers Pdf
*Embedded C Programming Interview Questions And Answers Multiple Choice
*Embedded C Programming Interview Questions And Answers 5th
*C Programming Tutorial
*C Programming useful Resources
*Selected Reading
Objective C Interview Questions: Read 20 Best Objective C Interview Questions and answers. Objective C is a computer language that guides in protest arranged programming. While choosing a possibility to deal with this programming language, a few objective C questions are inquired. An embedded system is a computer system that is part of a larger system or machine. It is a system with a dedicated function within a larger e Top 18 Embedded Systems Interview Questions & Answers.
Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is the output of the following code snippet?Answer : AExplanation
A, the range of ASCII values for the ASCII characters is 0-255. Hence the addition operation circulates back to ‘A’
Q 2 - What is the output of the following program?Answer : BExplanation
5 3, call by value mechanism can’t alter actual arguments.
Q 3 - What is the output of the following program?Answer : DExplanation
Compile error, wrong place for ‘break’ to appear.
Q 4 - What is the output of the following program?Answer : AExplanation
stdout is the identifier declared in the header file stdio.h which is connected to standard output device (monitor).
Q 5 - What is the output of the following program?Answer : DExplanation
It’s compile error as the declaration of main() mismatches with the definition.
Q 6 - int fun(); - The declaration indicates the presence of a function defined inside the current module or in the same file.Answer : AExplanation
The function definition can even appear in another source code and can be linked from library while linking.
Q 7 - The given below program allocates the memory, what function will you use to free the allocated memory?Answer : BExplanation
free() is the function in C language to release the allocated memory by any dynamic memory allocating built in library function.
Q 8 - Which of the following is a logical AND operator?Answer : BExplanation
Two immediate ampersand (&) symbols is logical AND operator.
Q 9 - Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers?Answer : AExplanation
Syntax is exp1?exp2:exp3. Any ‘exp’ can be a valid expression.
Q 10 - What will be the output of the given below code?Answer : AExplanation
Although, char str[] = ’Welcome’; and s = str;, the program will print the value of s.Details Last Updated: Tuesday, 10 January 2017 Hits: 55806 Top 60 complex and advanced C Interview Questions and Answers for Experienced programmers covering all aspects of C programming with detailed explanations.
1) What will be the output of printf(“%d”)?The ideal form of printf is printf(’%d’,x); where x is an integer variable. Executing this statement will print the value of x. But here, there is no variable is provided after %d so compiler will show garbage value. The reason is a bit tricky.When access specifiers are used in printf function, the compiler internally uses those specifiers to access the arguments in the argument stack. In ideal scenario compiler determines the variable offset based on the format specifiers provided. If we write printf(’%d’, x) then compiler first accesses the first specifier which is %d and depending on the that the offset of variable x in the memory is calculated. But the printf function takes variable arguments.
The first argument which contains strings to be printed or format specifiers is mandatory. Other than that, the arguments are optional.So, in case of only %d used without any variable in printf, the compiler may generate warning but will not cause any error. In this case, the correct offset based on %d is calculated by compiler but as the actual data variable is not present in that calculated location of memory, the printf will fetch integer size value and print whatever is there (which is garbage value to us).2) What is the return values of printf and scanf?
The printf function upon successful return, returns the number of characters printed in output device. So, printf(“A”) will return 1. The scanf function returns the number of input items successfully matched and assigned, which can be fewer than the format specifiers provided. It can also return zero in case of early matching failure.
3) How to free a block of memory previously allocated without using free?
If the pointer holding that memory address is passed to realloc with size argument as zero (like realloc(ptr, 0)) the the memory will be released.
4) How can you print a string containing ’%’ in printf?
There are no escape sequence provided for ’%’ in C. To print ’%’ one should use ’%%’, like -
5) What is use of %n in printf()?
Ans: According to man page “the number of characters written so far is stored into the integer. indicated by the int * (or variant) pointer argument.“. Meaning if we use it in printf, it will get the number of characters already written until %n is encountered and this number will stored in the variable provided. The variable must be an integer pointer.
Above program will print ’Hello world 5 “ as Hello is 5 letter.
6) Swap two variables without using any control statement ?
We can swap variable using 2 methods. First method is as given below
Second method to swap variables is given below
7) Consider the two structures Struct A and Struct B given below. What will be size of these structures?
struct A{ unsigned char c1 : 3; unsigned char c2 : 4; unsigned char c3 : 1;}a;
struct A{ unsigned char c1 : 3; unsigned char : 0; unsigned char c2 : 4; unsigned char c3 : 1;}a;
The size of the structures will be 1 and 2. In case of first structure, the members will be assigned a byte as follows -76543210c3c2c2c2c2c1c1c1
But in case of second structure -876543210c3c2c2c2c2c1c1c1
The :0 field (0 width bit field) forces the next bit width member assignment to start from the next nibble. By doing so, the c3 variable will be assigned a bit in the next byte, resulting the size of the structure to 2.
8) How to call a function before main()?
To call a function pragma startup directive should be used. Pragma startup can be used like this -
The output of the above program will be -
But this pragma directive is compiler dependent. Gcc does not support this. So, it will ignore the startup directive and will produce no error. But the output in that case will be -
9) What is rvalue and lvalue?
You can think lvalue as a left side operant in an assignment and rvalue is the right. Also, you can remember lavlue as location. So, the lvalue means a location where you can store any value. Say, for statement i = 20, the value 20 is to be stored in the location or address of the variable i. 20 here is rvalue. Then the 20 = I, statement is not valid. It will result in compilation error “lvalue required” as 20 does not represent any location.
10)How to pack a structure?
We can pack any structure using __attribute__((__packed__)) in gcc. Example -
We can also use, pragma pack like this -
In both cases the size of the structure will be 5. But remember, the pragma pack and the other method mentioned, both are compiler dependent.
11) How to convert a string to integer value?
We can convert a string to integer in two ways. Method 1:
Method 2:
12) Print the output of the following switch case program?
Output of this program will be 3. The position of the default is before case 1. So, even if there is no break after case 3, the execution will just exit switch case and it will not go to default case.
13) How to prevent same header file getting included multiple times?
We can use ifndef and define preprocessors. Say the header file is hdrfile.h, then we can write the header file like -
The ifndef will check whether macro HDRFILE_H_ is defined or not. If it is not defined, it will define the macro. From next time onward the statements inside ifndef will not be included.Embedded C Programming Interview Questions And Answers Pdf
14) Which is better #define or enum?
*Enum values can be automatically generated by compiler if we let it. But all the define values are to be mentioned specifically.
*Macro is preprocessor, so unlike enum which is a compile time entity, source code has no idea about these macros. So, the enum is better if we use a debugger to debug the code.
*If we use enum values in a switch and the default case is missing, some compiler will give a warning.
*Enum always makes identifiers of type int. But the macro let us choose between different integral types.
*Macro does not specifically maintain scope restriction unlike enum. For example -
Above program will print -
15) Print the output of this pointer program?Embedded C Programming Interview Questions And Answers Multiple Choice
The program will crash. The pointer p points to string “Pointers”. But the string in constant and C will not allow to change its values. Forcibly doing so, like we did it, will cause crash of the program.Embedded C Programming Interview Questions And Answers 5th
*Prev
*1
Download here: http://gg.gg/ob2z5
https://diarynote.indered.space
コメント