Tutorial Study Image

C Interview Questions

A Pointer variable than can hold the Address of other Pointer variable. Eg: int x = 3, *p= &x, **q= &p.

Malloc and Calloc are used to Allocate Memory, Both the functions allocate Memory dynamically from the Heap. In the case of Calloc, it allocates memory Initialized with Zeros.

The keyword Auto is a default storage class that is declared inside a Function. The scope of the Auto is inside the Function where it is declared. Auto Storage class is rarely used in C programming.

The Break is used to break the control out from the Block. The Break is used inside a Loop or a Switch statement.

 

for ( initialization, test expression, increment)
    {
             statements to be executed inside the loop

    }

 

Dangling pointers are Pointers that point to a Nonvalid Memory location or a nonappropriate Data type. its also called Wild Pointers.

Typecasting means we can change a Variable of one Data type into another Data type. we can understand the concept by an example if we have an Integer Data type and we have to store a Long int in that integer variable, then we can Typecast int to Long.

A memory leak is a type of resource leak, it happens when a program incorrectly Allocates or manages the Memory or when we forget to Free the Memory after the program.

A simple way to control or avoid Memory Leak is to write Free memory after the Malloc function or use the Calloc in the program. or use Memset with Malloc. also, be careful with Memory Allocation with Pointers.

Both are mainly used in the Loop for incrementing the value. The expression i++ returns the value and then it Increments, but in the ++i case, it returns the value after Incrementing.

The Array is collections of elements of the same Data type which can be accessed by an Index Variable. whereas Pointer is a variable that has the Address of another Variable. The Array can store a number of elements in a Sequence of Memory locations where the Pointer can hold the Address of one variable.

Storage classes define the features of a Function or a Variable it defines the Scope of a Variable. In C we have mainly Auto, Extern, Static, and Register Storage class specifiers.

The Base Address means from where the Array starts, it have the Address of the very first element in the Array.

L value is the value that appears on the Left Side of the Assignment operator "=". L value refers to a location in Memory that Identifies an Object. sometimes the memory locations can be modified which are called modifiable L value. R-value will appear on the Right Side of the Assignment operator which refers to a Data value that is stored in some Memory location.

Nested Structures mean, if we have a Structure that contains the Contents or Elements of another Structure, it is called a Nested Structure.

Suppose we don't know the Address to point for a Pointer, we declare the Pointer by Assigning the value of that pointer as Zero or Null which is called a Null Pointer. A Null Pointer is also referred to as a Null Reference in which the point is not referring to a Valid object.

L values are the Left-hand side value of an Assignment operator '='. it is having the Memory location of an object, L values are two types

  • Modifiable L value
  • Non-Modifiable L value.

Identifiers in C is a name given to a Variable, Arrays, Functions, Structures, etc. inside a C program.

RULES FOR WRITING AN IDENTIFIER

  1.  Identifiers must be Unique inside a program.
  2.  An identifier can include anything like Alphabets Numeric characters and Underscore. 
  3.  The starting character must be an Alphabet or an Underscore.
  4.  Identifiers are Sensitive to Uppercase and Lower case alphabets.[ case sensitive]
  5. Identifiers do not contain any Spaces in between.
  6.  Keywords are not Identifiers, do not use a Keyword as an Identifier.

In C programming, there are two types of Data types which are Fundamental data type and Derived data type.

Fundamental data type includes basic data types which are

  1.  Integer
  2.  Character
  3.  Floating point
  4.  Void.

Derived data types are data types that are derived from Fundamental Data types means which we group the fundamental data types. it includes

  1. Array
  2. Pointer
  3. Structure
  4. Union

String Constants are the fixed string values in c program which is enclosed in inverted commas, for example, "hello" is a String Constant. Constants in which there is no value inside it are called Null String constants which are denoted as " ". String constants are stored in the memory locations as an array of Characters indexed by an Index variable.

A Local and Global variable definition is based on the Scope or Visibility of the variable. If a variable is defined inside a function that has its Scope only inside that Function is called Local Variable. If the variable is defined outside the Function means it can be accessed anywhere from the program, it is called a Global Variable.

Static Variables have the values defined inside or outside the Function in which its value remain the same inside the Compiler till the program is running, which can be called to any Function. The scope of the Static variable is applicable through out the Program.

Both are used to pass the Parameters to a Function, In the Call by Value method the values are passed by copying the Variables to a Function.

In the Call by Reference method, we pass the Address of the variables.

In Dynamic Memory Allocation, the memory is Allocated during the Run time of a program, so the Memory can be increased during the program, Mainly the Memory is allocated from the Heap.

Methods of Dynamic Memory Allocation are

  1. Malloc()
  2. Calloc()
  3. Realloc()
  4. Free.

Dynamic Memory is allocated from Heap Memory. the main methods for the Memory Allocation are

  1. Malloc()
  2. Realloc()
  3. Calloc()
  4. Free

The values or variables that are passed to a Function while that function is called is known as Actual Parameter.

If the Parameters are used in the Function declaration, they are declared in the Function Prototype which is known as Formal Parameter.

Before the actual processing of the program, Preprocessors are programs that process the Source code. preprocessors are used for the Inclusion of Header files and # define in the C program.

In a Program A Function which calls Itself Repeatedly is called Recursion. in practicing Recursion the Exit condition must be mentioned.

Types of Recursion are

  • Linear Recursion
  • Binary Recursion
  • Multiple Recursion
  • Tail Recursion

A Pointer that is not able to point to another variable once it points to a variable is called a Constant Pointer. In other words, A pointer that cannot change the Address that it holds is called a Constant Pointer.

In C programming, a Token is the smallest element that a Compiler understands inside a Program. Examples of C Tokens are

  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Operators, etc.

Declare a variable means we are adding the Type to that variable like int, char, float, etc, but in the case of Defining a variable, First we are Declaring a variable and in addition to that we give or Assign a Value to the Variable like "int x = 10".

Variable declaration associates Type to the Variable, but variable definition gives Type and Value to the variable.

Structures that have some Pointers in it which point to the same Structure type are known as Self-referential structure. we can describe that as the Structures which point to the same Structure type.

An Array is a Data type in c which is a collection of elements of the same Data type which can be indexed by a common Index.

Pointers that are not initialized properly are called Wild Pointers, in other words, pointers point to the Random Memory Location which has some Junk values. Wild pointers make the program crash or end in a program Error.

Scanf() is a built-in function in Header library 'stdio.h'. Scanf() is used to Read and Accept an Input which may be a String or Numeric or anything from a user through a keyboard or any Input device.

IDE is the Integrated Development Environment, It is a user Interface between the Compiler which is used to write and execute a C program.

Pre-increment increments the value before it is assigned to a Variable. Where the Post-increment increments the value after that is assigned to a Variable.

A Compiler is a program that acts as an interface between the Machine and Human, It converts the Human-readable program into a format that the Machine understands which is called Machine Language. This processing of conversion is called Compilation.

Segmentation Fault is the most common Run time Error, which is caused because of accessing an Invalid Memory Location.

Memory Fault is happening when the program is using the Memory in an incorrect way or use the Memory which is not valid.

Single equal '=' is called the Assignment Operator which is used to assign a value to a variable.

Double equal '==' is called the Relational Operator which is used to Compare the values inside an if condition or something.

Arrays in C

  1. The Array is a collection of elements of the same Data type.
  2. Array elements are stored in a sequence of a Memory location.
  3. The Array's name has the Address of the starting element.

Linked List in C

  1. A Linked list is a linear data structure with Dynamic Memory Allocation.
  2. In the Linked list the elements are not stored in sequence of the Memory Location.
  3. A Linked list is Dynamic in nature. in case the Array has a fixed length.

Uninitialized pointers are also known as Wild Pointers. This points to a Random Memory location. These pointers may lead the program to behave wrongly.

Array size can't be declared during the Run time, the Size of the Array must be provided before the Compilation as an Array is not using Dynamic Memory Allocation like a Linked list.

Both are String functions in C programming where 'strcpy' is a function that is used to copy the complete String whereas 'strncpy' is used to copy a specific part of the String.

Pointers are used to store the Memory Address of a variable. Pointers are used to Allocate Memory Dynamically. Be careful to not have a Memory Leak while using Pointers.

Main is the Function in C programming where the program Execution Begins.

#define is a Preprocessor directive that is used to Define a Constant in C programming. constant may be integer, float, char, or any data type.

It is a preprocessor operator that is used to join two tokens. it is also called the operator for token pasting.

Pragma is a Preprocessor directive that is used to inform the compiler about some Additional information. it is also used by the Compiler for having some special Features.

Array

  1. It can hold any of the Data types
  2. Array size is fixed, cannot be changed
  3. It cannot be ended with a Null character

String

  1. It can be ended with Null (‘\0’) character
  2. It can hold only character Data type
  3. Here String size is not Fixed, can be changed 

The Pointer is a variable that stores the Address or Memory Location of another variable.

The File Pointer is used to handle and track the files being accessed. for declaring the File Pointer we use a new data type called 'File'.

Void pointer is a pointer that is not associated with any of the data types which means it can be used to point any of the other data types. it is also called a general-purpose pointer.

Due to some Segmentation Fault or Memory Fault, a dump error file is created when a program is crashed or terminated or we try to write a read-only memory or freed block memory which is called Core Dump in c.

As the name suggests, a Constant Pointer is a Pointer in which once it points to a variable by storing its address, then that address cannot be changed. This means once a Constant Pointer is used to point a variable we cant use that Pointer for point any other variable.

A Null Pointer is a pointer that points to nothing, which means it points towards no memory location. When we try to access a Null Pointer we will surely get an error and the program gets crashed, mostly we get a Segmentation Fault or Memory Fault.

Memcpy is a memory copy function that is used to copy some of the characters from one memory location to another memory.

Syntax

void *memcpy(void *destination, const void * source, size_t n).

 

Auto variables

Register variables

1. Auto are local variables. 1. Register are also local variables.
2. Stored in a memory location in the main CPU. 2. Stored in register memory.
3. It can be accessed but a bit slow. 3. it can be accessed faster as it stored in the register.

The Structure is a Derived Data Type, unlike Arrays, Structure can hold a group of elements that has different data type in a single block of memory.

We use the keyword Struct to represent the Structure. All elements in a Struct are called its members.

  1. In Arrays data can be easily sorted.
  2. In Arrays, traverse through data is easy.
  3. Array provide the random access through elements.
  4. Array are easy to declare and implement, so code optimized.

A union is a Derived Data Type that allows the programmer to store different data types in a memory location.

The Union is similar to Structure but the size of the Union is not like the whole size of members as in Structure. Union takes the size of its largest element only.

The operators are used to do an operation on a constant value or a variable, usually represented by a symbol. For example,

  1. Arithmetic
  2. Relational
  3. Bitwise Operators
  4. Logical, Shift Operators
  5. Assignment
  6. Ternary operators etc.

The Pointer is a variable that hold the Address of another variable, we can do some Arithmetic Operations on pointer.

  • Increment
  • Decrement
  • Addition
  • Subtraction
  • Comparison

One or more statements that together to perform a task that can be called is called a Function. Every C Program starts execution from the Main() function.

A function has a name, return type and the parameters to be passed into the function, the body of function which has the executable statement collection.

Function Advantages.

  • The code can be reused.
  • Code optimization
  1. Library Functions:

    Functions that are inbuilt in the header files which can be used inside any program when we include those header libraries are called Library functions, for example, Printf, Scanf, puts, etc.

  2. User-Defined Functions:

    The Functions that are written by the user to achieve a task or a calculation which is good to reduce program complexity and increases the reusability is called user-defined functions.

  3. Recursive Functions:

    A Function that calls itself until an exit criterion is found is called a Recursive Function.

Dynamic Memory Allocation is a method of Allocating Memory during the run time of a Program, memory is allocated from the Heap.

Methods for dynamic memory allocation are

  1. Malloc
  2. Calloc
  3. Realloc
  4. Free.

In C language, we are having a set of Characters and we include all the characters set into an ASCII set or an extended ASCII set. Apart from this, there are some characters which re not the part of any of these two sets is called an Escape Sequence.

It does not represent itself if we use it inside a string. Escape Sequence has 2 or 3 letters starting with a backslash '\'.

In Switch Case there will be number of cases to be selected for the user, If we didn't use the Break after the case, all the cases in that switch will be executed until the Break is found.

In C Programming, we have to make some decisions inside the program which means a yes or no condition, if it is a yes then a set of statements are executed, else the other set of the statements is executed.

Three types of Decision Control Statements in C.

  1. If
  2. If else
  3. Nested if

In C, we have to execute a set of statements in Loop until some condition have to meet, Loop control is used for that.

Different types of control statements are:

  1. For loop
  2. While
  3. Do While

Assembler

It is a program that converts an Assembly language which is a low-level language to Machine Language.

Compiler

It is a program that is used to convert a high-level human-readable code to Machine Language or object code.

The Interpreter

It is also a program that is similar to a Compiler but the translation is done line by line, which means the Interpreter converts each line by line where compilers read and convert full source code in a single step.

Enumeration is also called Keyword 'Enum' in C programming, which is a derived or user-defined datatype. Enum is used to assign a name to a constant which makes the program easy.

In C programming, the data is arranged in files in sequential order one after the other, which means in files data are arranged as one after the other in proper order.

In such situations to access data in a file, we have to read the data in files in continuous sequential order until the data is found. Here the reading of data is possible only one at a time.

The Syntax is the rules or the format to write a Statement or a Code in C programming, Syntax error occurs when we violate the rules or the format to write a Statement. It is a common type of error that is detected by the Compiler.

Debugging means finding and solving the errors that happened when we write a C program. There will be Compile-time errors and Run-time errors in a program. In debugging we have to find and solve all the errors to get the output.

Compile the program with debugging option -g, run the gdb, Debugging is done by using breakpoints inside the program, execute the program in gdb debugger. print all the values of variables to check that. use the gdb commands.

These types of errors occur during the running of a program, usually run time errors are related to the Allocation of memory like Memory Fault, Segmentation Fault, accessing Null Pointer, Memory Leak, etc. and also errors happening in the logic of a program.

Multidimensional Arrays are also called Array of Arrays, a common example of a Multidimensional Array is a Matrix, where the elements are stored in Table format. The size of the 2D Array is calculated using the size of all dimensions.

Dynamic Data Structures are really important in C programming which allows a user the efficient consumption of Memory. Dynamic Data Structures are allocating memory dynamically from the Heap, which can be increased or decreased during run time.

Binary Heap is a Binary Tree that is complete and has some order such that the parent node is either greater than the child node or the child node is greater than the parent node and that will be the same for all the nodes in the Binary Tree.

As the name suggests Stream is a continuous stream of bytes that flows in or out of the C program, all the Input and Output devices like the keyboard, the monitor is all under the Stream.

In the C program, all the execution starts with the Main Function.

  • Structure oriented the programs are divided into functions, wherein object-oriented the program is divided into modules called objects.
  • Structure oriented programming is task-oriented wherein Object-oriented programming is data-oriented.
  • In Structure-oriented data is passed between the functions and in Object-oriented data is hidden and not into the passing.

Yes, Compiling a C program doesn't need the Main function, but the C program execution starts only if it has a Main function.

Both are built-in Functions in stdlib.h header library and both are used to retrieve the Absolute Value. In abs it returns the absolute value of an Integer where the fabs() return the absolute value of a Float data type.

Header Files are also known as Library Files. Header files are included in a C program to use the inbuilt functions in the program, Header files have the prototypes and explanations of the functions used in the program.

In a Program we can divide the program into independent Subprograms called Modules, which can be used repeatedly to achieve some Functions is called Modular Programming. its used for Code Optimization.

No, Array is not using Dynamic Memory and it must be declared before the Compilation of the C program.

Advantages

  1. It can be used for complex iteration.
  2. Here Function call itself, so calling a function many times can be avoided

Disadvantages

  1. The Exit condition must be needed else it will make a Program crash
  2. In this Debugging will be difficult as the Function is calling itself.

The Stream is an Input sequence of Bytes, Text stream is made of ASCII values which are from 0 to 255 represent all the characters. Wherein Binary we have raw 0 and 1 which cannot be interpreted by a C Compiler.

Text streams are mainly used in the handling of Text files wherein Binary stream we can handle all types of files.

No, A variable Declaring means we are Assigning a Data type to the Variable whereas if we Define a variable means we are giving a Memory location and a value to the variable.

Prototype of a Function in a Program means Declaring a function inside the program. The Declaration includes

  • Function Name
  • Type
  • Return values.
  • Parameters.

Both are the methods to Pass the Parameters into a Function in C program.

In the Call by value method, we copy and Pass the Value of the variables as parameters into the function.

In the Call by reference method, we are sending the Address of the variable instead of sending the Value of the variable into a Function.

The Stack is a Data Structure where the data is stored and retrieved in the LIFO method which means Last In First Out. it is like a pile of coins.

The process of inserting value inserted into a Stack is called Push and retrieve the value from the Stack is called Pop.

In c program, the process of assigning a value to a variable or initialize a value to a variable is called initialization. It is very important in c programming else the variable may have some junk value cause the program error.

Compound statements are called Blocks which are a combination of two or more Statements which will be seen on another statement body which will be executed together. Blocks or Compound statements are mentioned in braces.

Preprocessor Directives are the statements that we include at the beginning of a C program with the help of the symbol '#'. Preprocessor Directives are used to Define the Constants in the program.

FIFO means 'First In First Out', just like the logic In a real queue. It is a method used in the insertion and Deletion of elements into a Data Structure called a Queue. Where the First element added into a Queue will be the First element out from the Queue.

The values which are to be passed into a Function when we call that Function is called Actual Arguments.

Wild pointers are uninitialized pointers in c code.This pointers may cause the program goes wrong or results in program crash.

Loops in C are:

  1. For loop
  2. While loop
  3. Do while loop
  4. Nested loop.

Here Do While is Exit controlled Loop where all others are Entry controlled Loops.

  1. Null Pointers are used to initialize a Pointer variable if we dont have a valid Memory Address to point.
  2. If we don't have to pass a valid Address to a Function we use the Null Pointer.
  3. Null Pointer is used to terminate a For Loop.

The Indirection operator is a Unary Operator which is represented by '*'. The Indirection operator is used to get the value from the Memory Location that a Pointer variable points to. It dereferences a Pointer.

No, Pointers are Variables which store the Address of a variable containing a value, so we cant able to Add the Pointers directly in C.

Stack Overflow is a condition that occurs when a Program tries to Add more elements into the Stack Memory more than the Allocated Memory in the Stack. Normally Infinite Recursion is most common problem causing a Stack Overflow.

The answer is a No, Because of the Naming Rules in C Programming, we cant able to start a Variable with a Number.

In C programming a Constant is an element in which that value cannot be changed during the program, It is a Hardcoded value.

Variable is an element in c where the value can be assigned at any time also, we have to declare the variable as any type.

  • Integer Constants
  • Character Constants
  • Floating point Constants
  • String Constants.

Environment Variables are variables that can be accessed by any program in C. When we declare an Environment Variable we can use that from anywhere in the C program.

No, Array Tag is used for storing the Array, so it cannot be changed.

We all know that the '++' Operator is used as an Increment Operator. So if this Operator is used before variable (i.e '++var'), the variable is incremented by one before using it in the expression. But if the operator is used after the variable(i.e 'var++'), the expression is first evaluated and then incremented by one.

Infinite Loop is a error condition in which a Loop is executed infinite number of times, it happens when the Exit Condition of the loop is not properly mentioned.

Pointers are the variable which stores the Address of another Variable, Operations on a Pointer are

  • Comparison.
  • Addition/subtraction(excluding void pointers).

String length is the number of characters in a String expects the end character '\0' of a String.

If we want to remove all definitions of a Macro, we use the #UNDEF which tells the Preprocessor to remove all the Definitions.

The answer is a No, In C we cannot compare two Structures or Structure Variables, we can compare the elements of two Structures. But in a rare case, the answer is a yes, we can compare two structure variables if the two structures are initialized with Calloc Memory Allocation or they are set with Memset.

The maximum Identifier length allowed in C language is 32 Characters in which 31 characters and an End Character.

This statement is Correct, 'goto' is a Statement which is used to Unconditional jump to a labeled statement from the 'goto'.

The Algorithm makes the C program easy. An Algorithm is a step by step procedure to solve a C program. It gives a detailed blueprint of the Logic and Implementation of the C program.

Random numbers can be generated using different Logic in C, but the easy method is to use the rand() function which generates Random Numbers.

Control Structures are the Backbone of a Procedure-oriented programming language. It forms the basic entities of the program which are,

  1. Sequence Structure: which are straight-line path.
  2. Selection Structure: which are for branchings like Yes or No condition.
  3. Loop Structure: it is used for looping some statements in c.

The Length of the String can be calculated using 'strlen()'. Strlen is a Function which takes the String as Input and returns the String length.

To Join two Strings in the C program, strcat() function is used which means String Concatenation. It copies the Second String to the end of the First String.

The Structure is a Derived data type that is used to store elements of different Data types. The Structure is used to store records in C.

Binary files are Files that have the Data in Binary format which is not a Human-readable format but Machine-readable, where as in Text files the data will be in Human-readable format written using ASCII set values.

It is called the End Null Character of a String, every String ends with a '\0' character.

Yes, we can Initialize a Variable with value while we Declaring the variable with a Data type.

Random Access Files are Files in which we can get access to any Random File Data without reading in sequence. Its usage is when a program need to read a Large File to search for some data, Random Access Files will be very useful.

No, toupper is a Function to convert a Lower Case letter to an Upper Case. toupper converts a letter from Lower Case to the Upper Case at a time.

Bitwise Operators are used for making Bit Masks, In which a Process of making a Bitstring, and by using that Bitstring we can select only certain Bits from byte is called Bit Mask.

It is a false statement because we cannot move a machine word.

With a Preprocessor in C, we can make the program

  • Easy to Read
  • Easy to Modify
  • Easy to Port or move to any architecture
  • Easy to Develop.

It is a Operation on String, that makes the two String combined together, Denoted as "strcat" Function. Using the String Concatenation Function second String is copied and pasted to the end of the First String.

Static Files can only be used after Defining it in the Header files, so this is a Wrong Statement.

Memcpy is used to copy a number of Bytes of Memory from one location to another, which means Memcpy can be used with any Data type.

Strcpy is a Function that is used to copy a string and paste it to another String. It works only with Strings or Char Data type.

The STRCMP Function is used to compare two Strings. It compares character by character until the null character is found in two Strings. Strcmp is case sensitive and if we want to compare without Case sensitive, use function 'STRCMPI'.

Strcmpi is almost the same as the strcmp function which compares two strings character by character until the null character is found. Strcmp is case sensitive where strcmpi is not case sensitive.
  1. Used as an Error value.
  2. Used as a Sentinel value.
  3. Used to stop Indirection in a Recursive Data Structure.

The Far Pointer is a 32-Bit Pointer which can access the Memory Location outside the current Segment. The Computer allocates a segment Register to store Far Pointer.

Near Pointer is a 16-bit Address in a given Memory of 16 bit enabled. It can access data of small size.

The Huge Pointer is almost the same as of Far Pointer as it is a 32-bit pointer that can access the Memory outside the Segment.

But Far Pointer is fixed, which means it cannot be changed once it is located in a place, but a huge pointer can be changed.

Nul is an ASCII Character, which is the First Character and represented by '\0'. whereas Null is used to represent the Null Pointer or a Built-in Constant which has value 0.

Locale.h is a Header file that Defines some location-related things like date, time format, currency, etc.

Goto, Break, Continue, Return are the Statements in C to move out of a Function

Signals are the Software-generated Interrupts that are sent to the process by the Operating System while the User presses some keys like ctrl + c, etc.

Conversion of Double to Float may be called Narrowing Conversion, which means it may lose some information about the Data Type. So It depends on the Compiler

'sprintf' is the same as of 'printf' but the 'sprintf' sends the Formatted String instead of sending the output to the Console as in 'printf'.

This statement is wrong, the '#include' statement is used to add the Headers Libraries into a program so it must be written at the very first of the program.

Jagged Arrays: are called Ragged Arrays which means it has an Array of Arrays in which the member Arrays have Different Sizes.

Argv[0] is a Command-line Argument, it represents the program name, and it returns a Null if the program name is not found.

Automatic Variables are also called Local variables which declared and used Inside a Block. In this type of variables, Memory is Allocated automatically when the control enters inside the Block and Free too when the control exits the block.

The result of Logical operation in C programming will be a Binary value which means 1 or 0

Relational Operators are used for checking the Relation between the Operands, it cannot be used with Structures that have different Data types.

Line Control is a Preprocessor Directive that is used to make understand the Compiler about the Location of the Source code, each Token location where it came from.

We can use the Keyword Extern for declaring Arrays when the Array size is optional.

String Operations can return the Data types of Void, Int, or Char.

  1. To reduce Memory usage.
  2. The value to be stored is beyond the Max Limit.
  3. The value to be stored is in a form not supported by that Data Type.

The First argument is a Filename and the Second argument is Access Mode.

This statement is False. Constant Variables need to be Defined before using it.

Short is the short form of 'Short Int' that is for declaring Int Data Type but uses two bytes of Memory for its storage. where Int is also used for declaring Integer Data type but the storage for Int is 4 bytes.

We use Char Data Type while declaring a Bit Field in C programming.

It writes Formatted data into the String.

It is a Type name defined in the Header library 'stdio.h'.

Conditional Inclusion is used to prevent the multiple Additions of Header files in a program.

  1. It Prevents Multiple Declarations of Variable.
  2. It Prevents Multiple Declarations of the same Function.
  3. Check for the Existence of a Variable and doing something if it exists.

The simplest way is using the inbuilt Function 'random()'.

'srand is used to set a starting point for Generating Random Numbers. It seeds the Random Number Generator.

Yes, the String Concatenation function adds the Null Character after Concatenating two Strings.

Enum is the Enumerated Data Type that makes the program easy and understandable. It is processed by using a Compiler.

int ungetc(int c, FILE *fp)

Return is used to return the control from a Function to the Main program, Return keyword can Define a return value from Function to the main program. If nothing is returned from the Function we can use Void.

The Switch is a kind of Selection Control Mechanism which is used to allow the value of a variable to change the Control Flow of program execution.

In other words, if we have a set of cases and we need to select one which matches the user input, we can use a switch case.
 

  • Apart from the normal variables, Static Variables remain in memory while the program is running.
  • Static Variable Memory is allocated in the Data segment.
  • It is auto initialized to Zero even we forget to Initialize.

The size of the Union is taken in accordance with the Size of the Largest member of the Union.

C is a Middle-level language, It is the Bridge between the High-level language and Machine language.

It is nothing but an Integrated Development Environment. It is a mechanism that provides a user interface with Compilers to Create, Compile, and Execute C programs.

A Newline which is represented by '\n', is used to make the Compiler understand that it is the End of a Line and to start a New Line.

Tokens are the building block of C language. Each and every small unit in a C program is called Tokens. These Tokens are constructed together to write a C program.

C Tokens are classified mainly into 6 types.

  • Keywords
  • Identifiers
  • Constants
  • Strings
  • Special symbols
  • Operators

Keywords are Reserved Words that have a predefined Function in C programming. Keywords have special meaning to the Compiler for, what to do.

Keywords are part of the Program Syntax. for example While, Break, Signed, etc are some of the examples for Keywords.

  • Local variables
  • Global variables
  • Environment variables

Local Variables are Variables used in the C program, that having scope only within the Function it was declared.

This means the Local Variables declared inside the Function can't be accessed from outside of the Function.

Operators are symbols that are used to perform some tasks in C like Addition, Logical comparing, etc. For example '+', '-'. etc

Operators or Symbols which are used to assign the values to the variables are called Assignment Operators, for example, =, +=, -=, /+, %=, etc are the Assignment Operators.

It is a Pointer that can't change the address of the variable it points to. Once this pointer is used to point to one variable, we can't use that Constant Pointer to point to any other variable.
 

Yes, All the Statements and Structures, Functions, Keywords, and all other things in C are Case Sensitive.

Modifiers are Keywords in C, which is used to change a Datatype, A Modifier defines how much Memory is Allocated to the variable. for example, Short, Long, Signed, etc.

 short,long,signed,unsigned,long long

It is the most common Unary Operator in C language, It is used to Calculate the size of a variable or any operand. It returns the Amount of Memory allocated if that is used with a Data type.

The successor of C language is B. Actually, C language is developed by Dennis Ritchie in Bell Laboratories for use in the Unix Operating System.

C Language


  1. It is a Middle-level language
  2. In C there is no Exception Handling mechanism
  3. C is Structure-oriented.

    JAVA


  1. Java is a High-level, Human-readable language.
  2. Exception handling is present in Java.
  3. Object-oriented programming language

C language

  1. Structure oriented programming language.
  2. Uses a top-down approach.
  3. Does not support user-defined data types.

C++ Language

  1. Object-oriented programming language.
  2. Design is a bottom-up approach.
  3. Supports user-defined data types.
  1. Flexibility
  2. Portability
  3. Interactivity
  4. Modularity
  5. Efficiency

In C, Arithmetic Operators are used to performing Arithmetic or Mathematical operations like Addition, Subtraction, Multiplication, Division, and Modulus in C programs.

Atexit() function in C programming is used to execute a C function during the program Exit or returning the Control from Function to the Main program.

"Memcpy" and "Memmove" functions are used to copy a sequence of data from one memory location to another location. But in the "Memcpy" function, we should be careful that the Source Memory and Destination Memory locations do not overlap. wherein "Memmove" it's not an issue at all.

The answer is a No, we can pass as many Arguments to the Function, It depends on the available Memory on the Stack.

An Array subscript is an Integer Constant that is used to get an element in an Array location, It can never be a Negative value. its Size is 1.

Void pointer is a type of Pointer in which it can be used to point a variable of any Data type. But Null pointer is a Pointer which is points to Nothing

Both are used for Allocating Memory. In Stack, memory is Allocated Statically whereas Heap memory is for Dynamic Memory Allocation.

Jagged Arrays are called as an Array of Arrays. A Jagged Array is an array in which its elements are also Arrays. each element arrays can be different Sizes and Dimensions.

  1. %d - Integer format specifier
  2. %c - Character format specifier
  3. %s - String format specifier
  4. %f - Float format specifier
  5. %u - Unsigned integer format specifier.

It is simply a Data storage format in which a Variable can store data to execute a Definite operation.They are used in C programs to specify a Variable before to use in a program.

 

Variables are classified into 3 types. They are:

  1.  Local variable
  2. Global variable
  3. Environment variable
  1. auto
  2. double
  3. int
  4. break
  5. switch
  6. long. etc


 

These Operators are used to find the Relation between two Variables. In other words these Operators compare the values of two Variables in a C program.

Operators that are used to perform the Logical Operations are called Logical operators. The Logical operators used in C programs are:

  1. Logical AND (&&)
  2. Logical OR (||)
  3. Logical NOT (!)

The Programming Language is a language that has a set of Instructions and Syntax which is used to make a Task running.

Embedded C is an application-level of C programming which is used to do programming in Microcontroller Devices.

Printf is a Built-in function that is Declared and Defined in a Header file 'stdio.h'. The Printf function is used to print output to the Output device.

The Void is an Empty Data type that is used in the Function declaration if the function doesn't return anything to the main program or Function.

The Break is used to break and get the Control out of a Loop in a Switch case statement. Else all the cases in the Switch will be executed and will eventually reach in a Program Error.

  1. Call by Reference
  2. Accessing array elements
  3. Dynamic memory allocation
  4. Data Structures like tree, graph, linked list, etc.

It is the process in which a Variable is Assigned with an Initial value before used in the program. Without this process, a Variable would have a junk value which results in Error outputs.

 

This function is used to find out the length of the String.

The Structure is a Derived Data Type that is used to store Records, which means Elements in a Structure can be different data types.

gets() function, which is a  Built-in function for accepting Input from the User, defined in the Header library 'stdio.h'.
 

The Stack data structure is like a pile of coins in which the method it uses for Adding and Deleting elements is LIFO, which means 'Last In First Out' like a pile.

 

Static Memory Allocation

Dynamic Memory Allocation

Used in arrays

Used in linked lists

Allocation of memory during compile time

Allocation of memory during run time

During execution, Memory can't be changed During execution, Memory can be changed

 

It is possible to pass the Arguments in a C program from the Command Prompt which is called Command-line Arguments. Command-line arguments are denoted by argc and argv[]. where argc is count and argv is the arguments.

Command-line Arguments are used to control the C program from outside the program without hardcoded values inside the program.

printf() function is used to print the “Character, String, Float, Integer, Octal, and Hexadecimal values” into the Output screen or any other Output device.

Scanf(), which means this function is used to Read Character, String, Numeric data from the keyboard, or other Input devices from the user. Both these functions are inbuilt library functions.

Stderr is an output stream used by the C program to send the Output Error messages to the Console, it sends the Diagnostic data to the Console.

Spaghetti Programming is also called a Tangled Web of Programming. A type of code in c program which happens because of the inexperience of a Programmer. Program control jumps from here and there and gets overlapped and finally gets complex, usage of a lot of goto statements makes the program complex.

A Bus Error is a fatal error raised by Hardware to make an Operating system to notify that a process is trying to access a memory that cannot physically be addressed by the CPU. The error may occur due to the following reasons.

  1. Invalid address
  2. Hardware errors of other devices.
  3. Accessing a physical address that does not correspond to any device.


 

Strcat Function which is also called as String Concatenation function that adds the second String to the end of the first String and adds the Null character at last.

getch() is a built-in Input function reads a single character from the user but the entered input is not displayed, since it doesn't use a Buffer.

getche() is also used to read the input from the user but different from getch(), getche displays the input which it reads.
 

Since it acts as an Intermediate between High level and Low-level languages, which means it supports both the functions of High level and Low-level languages

The word Volatile means " can be changed any time" same meaning here too. A variable declared as Volatile tells the Compiler that its value can be changed by External sources at any time.

Bitwise Operations are used to do the operations at the Bit Level. Used to manipulate Data at Bit Level. In C Bitwise operators are 

  1. & (bitwise AND)
  2. | (bitwise OR)
  3. ~ (bitwise OR)
  4. ^ (XOR)
  5. << (left shift)
  6. >> (right shift)

The Operator “*” is used as a Pointer to a Variable. For example '*b', where '*' is a Pointer to the variable 'b'.

The Operator “&” is used to get the Address of the Variable. For example, '&b' will give the Address of the variable 'b'.

Generally, Switch-case statements are used for the execution of a Case from a certain number of case statements in accordance with the Input from the User. But in some cases there will be no cases matching with the User Input, In that case, the Control jumps to Default case and execute that
 

A variable that is declared Static inside a Function, whose Scope does not end within that Function where it was declared, like Auto Variables. Local Static Variables have the same Scope of Auto Variables.

This statement is True. A variable can be both Constant and Volatile.

Dennis Ritchie found the language C in Bell Laboratories.

 Functions are mainly classified into two types.They are:

      1. Library Functions - These Functions are declared in Header files such as scanf(), printf(), gets(), puts(), ceil(), floor()  etc.

      2. User Defined Functions - These Functions are created by the C programmer itself to reduce the Complexity of the program.

 

  1. Program Development becomes Easy.
  2. The Modular and Structural program can be done.
  3. Individual Functions can be easily Built or Tested.
  4. A Function can call other functions and can also call itself.
  1. WIth Pointers, we can access the Memory Location.
  2. It reduces the complexity of the code and improves performance.
  3. Using Pointers we can return multiple values from a Function.



 

The Base Address of an Array means the starting Address of the Array. where the First Element is stored in the Array.
 

Stack Memory, which is the Statically Allocated Memory.

While calling a Function we need to Pass the Parameters to the called function, for doing that we have 2 methods.

  1. Call by Value
  2. Call by Reference

Using the 'GOTO' statement we can do Unconditional Branching, but be careful while using goto as it can leave to Spaghetti Code.

' Sizeof ' keyword is used to calculate the Size of a Variable or a Data type.

  1. Comparison
  2. Addition/ Subtraction(excluding Void pointers)

The length of the String is the number of Characters present in that String except the Null Character '\0', which represent the End of the String.

At the time of Preprocessing.

Reserved words are those words that are a part of the Standard Library of C language, they are also called Keywords. Reserved words have special meaning and purpose that cannot be used for any other purpose. Examples are Int, Void, Return, etc.

In C language, we have 32 keywords.

 

Assembler is a program that converts an Assembly level program into a Machine level program for Execution. it converts Basic operations and all into Machine Language.

It converts source code into Intermediate code and then this code is executed one by one. The interpreter runs the code step by step which means only after the execution of one step it goes to the next.

In Object-oriented Programming,  programs are divided into Objects and the primary focus is on the Data being operated and not on the Functions. The Object is data which have Unique properties.

  1. Data types are used to define a variable.
  2. It determines the size of variable, constant, and array
  3. It is a data storage format in which a variable can store data.

No. There is no such limit. Any number of Arguments can be passed to a Function.

Exit() stops the program normally and restores the Status Code to the parent program.

The statement is True, we can call the 'atexit' function many times in a program,. But the Execution will be in the Reverse order.

We can use the “#ifdef” Pre-processor to check Macro is defined or not.

In c the program execution starts from the main function. The main function contains two major sub-parts called the declaration section and the executable section

The Link section is really important which gives the Instruction the Compiler to Link the Functions from the Standard System Libraries.

  1. Pointer
  2. Array
  3. Structure
  4. Union

Free is a function that is used to Free the Memory which is Dynamically Allocated using any of these functions Malloc, Realloc, Calloc, Free add this Freed memory to the system.
   

 

In a c program,program elements are included.Every program elements in a c program are known as identifiers.Functions,arrays are the examples of identifiers

The Array is a Data type that is used to store a collection of variables of the same data type in sequence memory locations. Array size cannot be modified inside a program, Types of Arrays are:

  1. One dimensional Array
  2. Two-dimensional Array
  3. Three-dimensional Array 


 

Strings are a sequence of Characters that form an Array, end with a Null character (‘\0’). They are always enclosed with Double-quotes.

It is a type of specifier which makes the Compiler understands

  1. Where to store a variable
  2. How a variable is stored
  3. The initial value of the variable
  4. Life or scope of a variable.

Different types of Storage Class Specifiers are:

  • Auto
  • Extern
  • Static
  • Register

C Functions which are designed to perform Mathematical Operations are called Arithmetic Functions in C. For example

  • log()
  • sin()
  • cos()
  • tan()
  • pow()
  • trunc()

Case-control statements are simply statements that are used to execute only a Unique block of statements from a series of Blocks. Different types of Case-control statements are:

  1. Switch
  2. Break
  3. Continue
  4. Goto

Ternary operators are also called Conditional operators. This operator restores one value if the condition is True and restores another value if the condition is False.