Frequently asked C language Interview Questions and Answers. Tokens in C.

0

 Frequently asked C language Interview Questions and Answers. 

1.What is C language?

C language is a high-level programming language that is widely used to develop system software, application software, and hardware drivers. It was developed by Dennis Ritchie in the early 1970s at Bell Labs.


2.What is a pointer in C language?

A pointer in C language is a variable that stores the memory address of another variable. It is used to manipulate data stored in memory and to pass data by reference.


3.What is the difference between an array and a pointer?

An array is a collection of similar data types, while a pointer is a variable that stores the memory address of another variable. An array is a fixed-size data structure, while a pointer can point to any memory location. An array name represents the address of the first element of the array, while a pointer variable holds the address of a variable.


4.What is a structure in C language?

A structure in C language is a user-defined data type that groups related data items of different data types into a single unit. It allows us to create complex data types that can be easily accessed and manipulated.


5.What is a function in C language?

A function in C language is a block of code that performs a specific task. It is a modular approach to programming and helps in code reuse, readability, and maintenance.


6.What is the difference between call by value and call by reference?

In call by value, a copy of the value is passed to the function, and any changes made to the value inside the function are not reflected outside the function. In call by reference, the memory address of the value is passed to the function, and any changes made to the value inside the function are reflected outside the function.


7.What is recursion in C language?

Recursion in C language is a technique of calling a function within the same function. It allows us to solve complex problems by breaking them down into smaller sub-problems.


8.What is a file in C language?

A file in C language is a collection of related data stored on a secondary storage device, such as a hard disk. It is used to store data permanently, and it can be accessed and manipulated using file operations.


9.What is a header file in C language?

A header file in C language is a file that contains function declarations, macros, and other definitions that are shared across multiple source files. It allows us to reuse code and simplify code maintenance.


10.What is the difference between const and volatile in C language?

Const is used to define constants that cannot be modified, while volatile is used to declare variables whose values can be changed by external factors, such as hardware interrupts.


11.What is a preprocessor in C language?

A preprocessor in C language is a tool that processes the source code before it is compiled. It is used to define macros, include header files, and perform other tasks that help in code reuse and simplification.


12.What is the difference between malloc and calloc in C language?

Malloc is used to allocate memory dynamically, while calloc is used to allocate memory dynamically and initialize it to zero. Malloc returns a pointer to a block of memory, while calloc returns a pointer to an array of elements.


13.What is a static variable in C language?

A static variable in C language is a variable that retains its value between function calls. It is initialized only once and retains its value until the end of the program.


14.What is the difference between local and global variables in C language?

Local variables are declared inside a function and have a local scope. They are accessible only within the function. Global variables are declared outside any function and have a global scope. They are accessible from any function in the program.

Tokens in C

In the C language, a token is the smallest unit of a program that the compiler can understand. Tokens can be classified into different types such as identifiers, keywords, constants, operators, and special characters.

An identifier is a name given to a variable, function, or any other user-defined entity in the program. Identifiers can consist of letters, digits, and underscore characters, but they cannot start with a Digit.


Keywords are reserved words that have predefined meanings in the C language. Examples of keywords include "if", "else", "while", "for", and "return".

Constants are values that remain unchanged during the execution of a program. Constants can be of different types such as integer constants, character constants, and floating-point constants.


Operators are symbols that perform arithmetic, relational, logical, or bitwise operations on the operands. Examples of operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).

Special characters are symbols used to separate different parts of the program or to represent certain values. Examples of special characters include semicolon (;), comma (,), parentheses (()), and braces ({}).

In C programming language, a program is made up of a series of tokens that are parsed by the compiler to produce an executable program. Each token has a specific meaning and usage in the program. By understanding the different types of tokens in C, programmers can write effective and efficient programs that are easy to read, debug, and maintain.





Tags

Post a Comment

0Comments
Post a Comment (0)