Interview Questions
- What are Escape Characters in C Language?
- How do you comment code in C Language?
- What is an Enum?
- What is a typedef?
What are Escape Characters in C Language?
\n, \t are called Escape characters. They represent characters like new line, tab in C Language.This provides a general and extensible mechanism for representing hard-to-type or invisible characters.
How do you comment code in C Language?
Below program shows both the types of comments in C Language : Single line comment and Multi line comment.
int main() { int i = 0; //FIRST COMMENT EXAMPLE : SINGLE LINE COMMENT /* * THIS IS * A * MULTI LINE COMMENT */ }
What is an Enum?
An enumeration is a list of constant integer values, as in enum boolean { NO, YES }; Below example shows another Enum in play.
#include <stdio.h> #include <stdlib.h> enum Boolean {TRUE, FALSE}; int main() { enum Boolean bool1,bool2; bool1 = TRUE; bool2 = FALSE; }
What is a typedef?
C provides a facility called typedef for creating new data type names. Below program shows two variations of typedef.
#include <stdio.h> #include <stdlib.h> enum Boolean {TRUE, FALSE}; typedef enum Boolean boolean; typedef int number; int main() { number marks = 5; boolean bool1,bool2; bool1 = TRUE; bool2 = FALSE; printf("%d",marks); }