15. What Is An Unsigned Integer Constant? What Is The Significance Of Declaring A Constant As Unsigned?
Answer: An integer constant is any number in the range -32768 to +32767, because an integer constant always occupies two bytes in memory and in two bytes we cannot store a number bigger than +32767 or smaller than -32768. Out of the two bytes to store an integer, the highest bit is used to store the sign of the integer.
This bit is 1 if the number is negative and 0 if number is positive. Unsigned integer constant is an integer constant which has the permissible range from 0 to 65536.
Significance of declaring a constant as unsigned almost doubles the size of the largest possible value. This happens because on declaring a constant as unsigned, the sixteenth bit is free and is not used to store the sign of the constant.
16. Differentiate Between Break & Continue Statement?
Answer: Two keywords that are very important to looping are break and continue. The break command will exit the most immediately surrounding loop regardless of what the conditions of the loop are. Break is useful if we want to exit a loop under special circumstances.
Continue is another keyword that controls the flow of loops. If we are executing a loop and hit a continue statement, the loop will stop its current iteration, update itself (in the case of for loops) and begin to execute again from the top.
Essentially, the continue statement is saying "this iteration of the loop is done; let's continue with the loop without executing whatever code comes after me."
The syntax of continue statement is simple continue;
17. Differentiate Between GoTo & Break Statement?
Answer: C support GoTo statement to branch unconditionally from one point to another in the program. The goto keyword is followed by a label, which is basically some identifier placed elsewhere in the program where the control is to be transferred.
During running of a program, the statement like "goto label1;" cause the flow of control to the statement immediately following the label "label1". We can have a forward jump or a backward jump.
#include <stdio.h >
void main()
{
int attempt, number = 46;
looping: /* a label */
printf("Guess a number from 0-100\n");
scanf("%d", & amp; attempt);
if (number == attempt) {
printf("You guessed correctly!\n\n");
} else {
printf("Let me ask again...\n\n");
goto looping; /* Jump to the label*/
}
getch();
}
whereas Break is useful if we want to exit a loop under special circumstances.
#include <stdio.h>
void main()
{
int a;
printf("Pick a number from 1 to 4:\n");
scanf("%d", & amp; a);
switch (a) {
case 1:
printf("You chose number 1\n");
break;
case 2:
printf("You chose number 2\n");
break;
default:
printf("That's not 1,2,3 or 4!\n");
}
getch();
}
18. What Is The Purpose Of The Do-While Loop In C?
Answer: Do-while loop or post tested loop is the loop used when it is necessary to execute the loop at least once in the execution of the program. The syntax of the do-while loop is:
do
{
loop body
} while (condition);
19. What Is The Difference Between Uses Of For & While Loops?
Answer: When a user wants to initialize, check condition and increment or decrement the value of a variable in a single statement, and using an iterative loop, then the loop used may be for loop.
When the user wants to initialize, check condition and increment or decrement value not using a single iterative loop, then he/she may use the while loop. Only one condition can be checked using the while loop.
20. What Is The Importance Or Purpose Of Main () Function?
Answer: main() is a special function used by C system to tell the computer where the program
starts.
The main() function in C is the most vital part of a program. The program execution occurs from the main() function. The main() function may contain any number of statements and they are sequentially executed. main() function can in turn call other functions.
21. Which Header File Is Used For Screen Handling Function?
Answer: The header file stdio.h contains definitions of constants, macros and types, along with
function declarations for standard I/O functions.
Check Out Other Questions:
16) What are the differences between a structure and a union?
17) What is meant by union?
18) What are the advantages of unions?
19) How can typedef be used to define a type of structure?
20) What is enumeration constant?
21) What is the purpose of main() function?
22) What are the differences between formal arguments and actual arguments of a function?
23) What is call by value in functions?
24) What is call by reference in functions?
25) What are the differences between getchar() and scanf() functions for reading strings?
...Return To C Questions INDEX.
...Return To C Programming INDEX.
... Return To HR Interview Index
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com