Skip to main content

C Programming Interview Questions With Answers - Part III.


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

Popular posts from this blog

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview . That's why this statement is often called the "Positioning Statement". One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly. YOUR ANSWERS CAN BE: 1) I am a person with strong interpersonal skills and have the ability to get along well with people . I enjoy challenges and looking for creative solutions to problems. 2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies apti...

HR Interview Questions With Simple Answers - Top 30.

Here are some very important HR questions which are often asked during Interviews and I believe these answers can really help you to get through....... Click on them to view the answer: 1) Tell Me Something About Yourself ? 2) What Are Your Strengths? 3) What Are Your Weaknesses? 4) How Do You Handle Pressure / Can You Work Well Under Pressure? 5) What Are Your Short Term Goals? 6) What Are Your Long Term Goals? 7) Where Do You See After 5 Years? 8) Why Should We Hire You? 9) What Is Your Salary Expectation? 10) Why Do You Want To Leave Your Current Job? 11) Do You Prefer To Work Alone Or As A Team Player? 12) What Made You Choose Your Major / Stream? 13) Why Didn’t You Pursue A Career In Your Major / Stream? 14) Why Do You Want To Work For Us? 15) Are You Willing To Travel? 16) Are You Willing To Take Risks? 17) What Do You Know About This Company? 18) What Do You Seek From A Job? 19) How Do You Evaluate Success? 20) Dur...

Sample Cover Letter / Job Application.

To The General Manager (HR) [ Name and Designation (Bold Words)] Infosys Limited Delhi – 110001 Uttam Agrawal Gandhi Chowk, Bhartee Street [ Name Bhawanipatna, Kalahandi Contact Address Orissa – 766001 Telephone No.] Ph. no - +91-9438170446 [Sub: Application for the position of ___________ in your esteemed organization.] Respected Sir, (Always use ‘Respected’) With reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ___________ . I would like to place myself as a strong contender before you. OR This has reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ____________. In the said connection I take this opportunity to apply for the said position as a strong contender. /*This is the Introduction i.e the first paragraph of your application/* ( Now the Second Paragraph is the Self Introduction) Try to start the second paragraph with the below mentioned lines: - I have the p...