C Interview Questions - Miscellaneous

We discuss various Miscellaneous C Language interview questions - Enum, Comments, typedef and escape characters.

Interview Questions

  1. What are Escape Characters in C Language?
  2. How do you comment code in C Language?
  3. What is an Enum?
  4. 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);
}
FREE JAVA INTERVIEW GUIDE

ONE SUBSCRIBER EVERY MONTH WINS 100% DISCOUNT CODE FOR INTERVIEW GUIDE WITH 23 VIDEOS

We Respect Your Privacy