Short Answer Questions with Answers

QNo 1-: Who Developed C programming language?

Dennis Ritchie in 1972 at BELL labs

QNo 2-: What type of language C is?

C is procedure oriented language and C is a general purpose language.

QNo 3-: What are the features of C language?

C exhibits the following features.

  1. User friendly language
  2. Easy to learn
  3. General purpose programming language
  4. Compatible with all machines and platforms
  5. Can be used for embedded Software design

QNo 4-: What is meant by High level language?

A programming language which can be understand by humans is known as High level language. Generally High Level Language similar to English. Examples: C, C++, Java, FORTRAN, COBOL etc.

QNo 5-: What is meant by Machine level language?

The language which is understand by machines is called as Machine Level Language. Generally it is represented with 0’s and 1’s. This is also called as binary language or low level language. Humans cannot understand this language.

QNo 6-: History of C language?

BCPL stands for Basic Computer Programming Language

QNo 7-: Define Algorithm.

Step by step process to solve a problem is known as Algorithm. Any problem can be solved with the help of algorithm. The algorithms are used in system design or programming as a preliminary design.

Q No 8 :- Explain the characteristics algorithm

Every algorithms must have the following characteristics those are

  • Finiteness: Algorithms must have finite steps
  • Input: Every algorithm may take zero or more than zero
  • Output: Every algorithm must produce at least one or more outputs
  • Unambiguous: The algorithm statements must be clear to understand
  • Efficient: Algorithm must be efficient

    Q No 9 :- What is Flowchart?

    Pictorial representation of algorithm is known as Flowchart. Flowchart gives problem solution diagrammatically. In flowchart various symbols are used to represent various activities. Even though Algorithm and flowcharts serves same purpose but flowcharts makes the user to understand system more easily than algorithm.

    Q No 10 :- List out the symbols used in Flowcharts and their activity?

    Q No 11 :- What are the data types are present in C language?

    C language supports 3 different types of data types those are

  • Primitive Data types
  • Extended data types
  • User Defined data types

    Q No 12 :- List out the primitive data types supported by C language?

    Primitive data type are

  • Int
  • Float
  • Char

    Q No 13 :- List out the extended data types supported by C language?

  • Arrays
  • Structures
  • Unions
  • Q No 14 :-List out the User data types supported by C language?

    Enum

    Q No 15 :- What is Interperter?

    Interpreter is a translator which converts the high level language into low level language line by line. It means interpreter converts the high level language instructions into low level language statement by statement. If any error encountered in a line then the interpreter stops conversion there itself. If the error is removed then it resumes the conversion.

    Q No 16 :- What is Compiler?

    Compiler converts the high level language program all instructions at a time. At the end of the translation it lists out the errors if present.

    Q No 17 :- Differentiate Compiler and Interpreter

    Differences Between Compiler and Interpreter

    Interpreter Compiler
    Conversion is done statement by staement Entire program is converted at a time
    Slower than Compiler Faster
    Conversion process is stopped if error appears. Conversion is done irrespective of errors.
    Easys to implement Complex to implement

    Q No 18 :- List out the operators of C language

    Operators in C

    Operators are the special characters represent a specific operation. The operation on which performed is called as operands. Based on the operands there are two different operators are present those are

    1. Unary Operators
    2. Binary Operators
    based on type of operation the operators types are
    1. Arithmetic Operators
    2. Logical Operators
    3. Bitwise Logical Operators
    4. Relational Operators
    5. Increment and Decrement Operators
    6. Terniary Operator
    7. Special Operators

    Q No 19 :- Write about Arithmetic operators of C language

    Ans:- Arithmetic Operators are the operators which are used arithemetic operations like Addition , Subtraction, Multiplication, Division.

    • + is used for Addition
    • - is used for Subtraction
    • * is used for Multiplication
    • / is used for Division
    • % is used for Finding reminder of integer division

    Q No 20 :- Write about Logical operators of C language

    Ans:-

    Logical Operators

    In C programming, logical operators are used to perform logical operations on boolean values (i.e., values that are either true or false). C provides three main logical operators:

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

    Q No 21 :- Write about Bitwise Logical operators of C language

    Ans:-

    Bitwise Logical Operators in C

    Bitwise logical Operators are the operators which are used to do Bitwise logical operations like AND , OR and NOT. The Bitwise operation is performed on the bits of the operands rather than the values. When we apply these operations on the operands the operations are perfomed on the binary equivalent of the operands.
    & is used for AND
    | is used for OR
    ~ is used for NOT

    Q No 22 :- Write about Relational operators of C language

    Ans:-

    Relational Operators in C

    In C, relational operators are used to compare two values and determine the relationship between them. These operators return a Boolean value, which is either true (represented as 1) or false (represented as 0), indicating whether the specified relationship holds true or not. Relational operators are commonly used in conditional statements to make decisions based on the result of the comparison. Here are the relational operators in C:

    Equality operator (==):

    Syntax: expression1 == expression2
    Description: Checks if expression1 is equal to expression2. It returns true if both expressions have the same value, and false otherwise. Example:
    if (x == y) {
    // This block will execute if 'x' is equal to 'y'.
    }

    Inequality operator (!=):

    Syntax: expression1 != expression2 Description: Checks if expression1 is not equal to expression2. It returns true if the expressions have different values, and false if they are equal. Example:
    if (x != y) {
    // This block will execute if 'x' is not equal to 'y'.
    }

    Greater than operator (>):

    Syntax: expression1 > expression2
    Description: Checks if expression1 is greater than expression2. It returns true if expression1 is greater, and false otherwise. Example:
    if (x > y) {
    // This block will execute if 'x' is greater than 'y'.
    }

    Less than operator (<):

    Syntax: expression1 < expression2
    Description: Checks if expression1 is less than expression2. It returns true if expression1 is smaller, and false otherwise. Example:
    if (x < y) {
    // This block will execute if 'x' is less than 'y'.
    }

    Greater than or equal to operator (>=):

    Syntax: expression1 >= expression2
    Description: Checks if expression1 is greater than or equal to expression2. It returns true if expression1 is greater or equal, and false otherwise. Example:
    if (x >= y) {
    // This block will execute if 'x' is greater than or equal to 'y'.
    }

    Less than or equal to operator (<=):

    Syntax: expression1 <= expression2
    Description: Checks if expression1 is less than or equal to expression2. It returns true if expression1 is smaller or equal, and false otherwise. Example: if (x <= y) {
    // This block will execute if 'x' is less than or equal to 'y'.
    }
    Relational operators are fundamental for comparing values and making decisions in C programs. They are often used in conjunction with conditional statements (e.g., if, else if, switch) to control the flow of the program based on specific conditions.

    Q No 23 :-What is meant by variable?

    Ans:- Variable is a name given to a memory location. In generally we do computaions on some values or numbers. These values are stored in computer memory in some address location. If we want to access the values we have to use the memory address which is very complex task to remember the memory location (address). In order to over come this problem a name is given to the address. Remembering name is easier than memory location.

    Q No 24 :-What the rules to be followed while creating variable?

    Ans:-

    1. Varialble should not be a keywords
    2. varible should not starts with a digit.
    3. Varialbe may contains charctes and digits but not any specila symbol
    4. varilable size may be any size
    5. variable must be meaningful name

    Q No 25 :-List out some keyword of c language

    Ans:-

    1. Varialble should not be a keywords
    2. varible should not starts with a digit.
    3. Varialbe may contains charctes and digits but not any specila symbol
    4. varilable size may be any size
    5. variable must be meaningful name

    Q No 26 :-Explain about Unary operators of c language

    Ans:- Operators are the special characters represent a specific operation. The operation on which performed is called as operands. Based on the operands there are two different operators are present those are

    1. Unary Operators
    2. Binary Operators
    Operators which are applied on single operand are called as unary operators. Increment decrement operators comes under unary operators. There are two different types of unary operators are present. Those
    1. increment operator (++)
    2. decrement operator (--)

    Increment and Decrement Operators

    There are increment and decrement operators are present in C.

    ++ Operator

    ++ operato is called as increment operator. This operator is used on a single operand hence it is called as unary operator. This operator adds 1 to the operand.


    int a=10
    a = a++ // result is 11

    -- Operator

    ii operato is called as decrement operator. This operator is used on a single operand hence it is called as unary operator. This operator subracts 1 from the operand.


    int a=10
    a = a-- // result is 9

    Q No 27 :-Explain about Conditional operators of c language

    Ans:- Conditional Operators also known as Ternary operator is only one operator present in C. The ternary operator is combination of two special characters those are ? and :. The ternary operator is exactly replaces the if else control block. Shortest form of if else is ternary operator.

    Syntax of ternary operator.
    (conditional statement)? statement1 : statement2;

    First the conditional statement is checked if it is true then the statement1 is executed if is is false statement2 is executed.

    Q No 28 :-Write Structure of C Program

    Ans:- Every programming language laid out some rules to be followed when we are writing programs. The collection of rules to write a program is known as structure.

    Structure to be followed in the given order

    1) Prepocessor direcitves
    2) Global varilabe diclaration if any
    3) Functions declaration if any
    4) main function definition
    5) user defined functions definition if any

    Q No 29 :-Write about preprocessor derectives and give examples of preprocessor directives

    Ans:- Preprocessor directives are the instructions given to system which are processed before actual exectuion of a program. In preprocessor directives we include the header files which are to be fetched and included before execution of the actual program.
    Examples:
    #include<stdio.h>
    #include<string.h>

    Q No 30 :-Write use of printf() and scanf() functions

    Ans:- printf() is used to print the messages on the output device. printf() is out put function.
    scanf() is used to initialize the variable in runtime. scanf() is input function.

    Q No 31 :-List out the control flow statement in C language

    Ans:- There are 2 different types of control flow statements those are:
    1) Conditional Control Flow statements. Example: if, if-else, if else if, switch
    2) Iterative Control Flow statements. Example: for, while, do- while.

    Q No 32 :-Explain How "if" works and write the syntax of if in C language

    Ans:-

    Understanding the "if" Control Statement in C

    Control statements are an essential part of programming languages and play a crucial role in determining the flow of execution in a program. One commonly used control statement in C is the "if" statement. The "if" statement allows programmers to specify a condition that, if true, will execute a block of code.

    Basic Syntax of the "if" Statement

    The basic syntax of the "if" statement in C is as follows:

    if (condition) { // code block to be executed if the condition is true
    }

    The "condition" in the above syntax is a Boolean expression that evaluates to either true or false. For example, consider the following code snippet:

    if (x > 5) {
    // code to be executed if x is greater than 5
    // code to be executed if the condition is true
    }

    Q No 33 :-Explain How "if lese" works and write the syntax of if-else in C language

    Ans:-

    Understanding the "if else" Control Statement in C

    Control statements are an essential part of programming languages and play a crucial role in determining the flow of execution in a program. The "if" statement allows programmers to specify a condition that, if true, will execute a block of code. if the if condition is false then else block is executed

    Basic Syntax of the "if else" Statement

    The basic syntax of the "if" statement in C is as follows:


    if (condition) { // code block to be executed if the condition is true
    } else{ // code block to be executed }

    The "condition" in the above syntax is a Boolean expression that evaluates to either true or false. For example, consider the following code snippet:

    if (x > 5) {
    // code to be executed if x is greater than 5
    // code to be executed if the condition is true
    }
    else{

    // code to be executed if x is less than 5
    // code to be executed if the condition is false
    }

    Q No 34 :-Explain How "if lese if" works and write the syntax of if else if in C language

    Ans:-

    Understanding the "if else if" Control Statement in C

    Control statements are an essential part of programming languages and play a crucial role in determining the flow of execution in a program. If some problem we have to check many conditions to be checked in this scenario if and if else will not work. For this a new control statement is required in which is called as if else if control flow statement. In this the control flow starts with if condition and ends with else block. In between if , else one or more than one else if blocks will be present. Each else if block consists of one condition statement if the condition is ture then the purticular else if block will be executed else next subsequent else if block condtion will be checked. if none of the else if conditons are true then else block will be executed.

    Basic Syntax of the "if else if" Statement

    The basic syntax of the "if else if s" statement in C is as follows:


    if (condition1) { // code block to be executed if the condition is true
    }
    else if(condition2 ){
    // code block to be executed
    }
    else if(condition3 ){
    // code block to be executed
    }
    ... else{
    //code
    }

    Q No 35 :-Explain How "switch" works and write the syntax of switch in C language

    Ans:-

    Understanding the "Switch" Control Statement in C

    Switch works same as if else if but the syntax is very compact and very neat.

    Basic Syntax of the "switch" Statement

    The basic syntax of the "Switch" statement in C is as follows:


    switch (constant/variable/equation) {
    case 1: code
    break;
    case 2: code
    break;
    case 3: code
    break;
    .... default: code
    break;
    }

    Q No 36 :-Explain for loop in C language

    Ans:- A for loop in C is a control flow statement that allows you to repeat a block of code a specified number of times. The for loop has the following syntax: for (initialization; condition; update/increment/decrement) {
    // statement block to be executed repeatedly }
    The initialization statement is executed once, before the loop starts. The condition statement is evaluated before each iteration of the loop. If the condition is true, the statement block is executed. If the condition is false, the loop terminates. The update statement is executed after each iteration of the loop. The update statement can be used to increment or decrement a variable, or to change the value of a variable in some other way. Here is an example of a for loop in C: C
    for (int i = 0; i < 10; i++) {
    System.out.println(i);
    }
    This code will print the numbers from 0 to 9. The initialization statement declares a variable named i and initializes it to 0. The condition statement evaluates whether i is less than 10. If it is, the statement block is executed. The statement block prints the value of i. The update statement increments i by 1. This ensures that the condition statement will eventually be false, and the loop will terminate. The for loop is a powerful tool for repeating a block of code a specified number of times. It is a common control flow statement in , and it is used in many different programming tasks. Here are some of the benefits of using for loops in C:

    • They are easy to read and understand. The for loop syntax is very simple and straightforward, which makes it easy to read and understand.
    • They are efficient. The for loop is a very efficient way to repeat a block of code. This is because the compiler can optimize the loop code for better performance.
    • They are versatile. The for loop can be used to repeat a block of code for a variety of purposes. This makes it a very versatile tool in the C programming language.
    If you are looking for a way to repeat a block of code a specified number of times in C, the for loop is a good option. It is easy to read, efficient, and versatile.

    Q No 37 :-Explain while loop in C language

    Ans:-

    A while loop in C is a control flow statement that allows you to repeat a block of code a specified number of times.

    The while loop has the following syntax:

    initialization;
    while ( condition ) {
    // statement block to be executed repeatedly
    update/increment/decrement
    }

    The initialization statement is executed before start of while once. The condition statement is evaluated before each iteration of the loop. If the condition is true, the statement block is executed. If the condition is false, the loop terminates. The update statement is executed after each iteration of the loop. The update statement can be used to increment or decrement a variable, or to change the value of a variable in some other way.

    Here is an example of a for loop in C:

    int i = 0;
    while ( i < 10) {
    System.out.println(i);
    i++
    }

    This code will print the numbers from 0 to 9. The initialization statement declares a variable named i and initializes it to 0. The condition statement evaluates whether i is less than 10. If it is, the statement block is executed. The statement block prints the value of i. The update statement increments i by 1. This ensures that the condition statement will eventually be false, and the loop will terminate. The for loop is a powerful tool for repeating a block of code a specified number of times. It is a common control flow statement in C, and it is used in many different programming tasks.

    Q No 38 :-Explain do while loop in C language

    Ans:-

    A do while loop in C is a control flow statement that allows you to repeat a block of code a specified number of times.

    The do while loop has the following syntax:

    initialization;
    do{
    // statement block to be executed repeatedly
    update/increment/decrement
    }while ( condition ) ;

    The initialization statement is executed before start of while once. The condition statement is evaluated after execution of do block. If the condition is true, the do block is executed. If the condition is false, the loop terminates. The update statement is executed after each iteration of the loop. The update statement can be used to increment or decrement a variable, or to change the value of a variable in some other way.

    Here is an example of a for loop in C:

    int i = 0;
    do{
    System.out.println(i);
    i++
    }while ( i < 10) ;

    This code will print the numbers from 0 to 9. The initialization statement declares a variable named i and initializes it to 0. The condition statement evaluates whether i is less than 10. If it is, the statement block is executed. The statement block prints the value of i. The update statement increments i by 1. This ensures that the condition statement will eventually be false, and the loop will terminate. The for loop is a powerful tool for repeating a block of code a specified number of times. It is a common control flow statement in C, and it is used in many different programming tasks.

    Q No 39 :- Write the difference between while and do while loop

    Differences Between while and do-while

    while do-while
    Condition is checked before executing the iterative statements. Condition is checked after executing the iterative statements.
    Semicolon is not used after while. Semicolon is used after while.
    while Syntax:

    initialization;
    while ( condition ) {
    // statement block to be executed repeatedly
    update/increment/decrement
    }

    do while syntax:

    initialization;
    do {
    // statement block to be executed repeatedly
    update/increment/decrement
    }while( condition ) ;

    Q No 40 :-Deifine Array

    Ans:- Array is collection of homegenious elements. It means array consists of same type of elements. Array can be any type. It may integer , float or character. Syntax of Array Declaration:
    datatype arrayname[size of array];
    Example:
    int marks[10];

    Q No 41 :-How to initialize Array and display array elements?

    Ans:- Array can be initialized by specifying the index in the squire brackets. If we want to initialize first element then we have to specify as follows
    marks[0]=20;
    The above statement can be interpreted as first element of marks array is initilizes with 20; Similarly if we want access or display we have to specify the index of the array which we want to access. Example
    printf("%d", marks[2]);
    The above print statement prints third element of marks array.

    Q No 42 :-List out the types of array supported by C languate?

    Ans:- There are three types of arrays in C those are

    1. Single Dimensional Arrays
    2. Double Dimensional Arrays
    3. Multi Dimensional Arrays

    Q No 43 :-Deifine String

    Ans:- Sring is collection of characters. Strings can be implemented by using character arrays. Syntax of String Declaration:
    char arrayname[size of array];
    Example:
    char name[10];

    Q No 44 :- Write String handling functions

    Ans:- String Handlingl Functions: strlen(): This function returns the length of the given string.
    strcpy(): This function is used to copy string in to another string.
    strcmp(): This function is used to compare two strings.
    strcat(): This function is used to concatenate two strings
    strupr(): This function returns the upper case of the given string.
    strlwr(): This function returns the lower case of the given string.

    Q No 45 :-Deifine Structure

    Ans:-

    Structure

    Structure is a user defined data type which hold or store heterogeneous/different types data item or element in a single variable. It is a Combination of primitive and derived data type.
    or
    A structure is a collection of one or more data items of different data types, grouped together under a single name.
    Variables inside the structure are called members of structure. Each element of a structure is called a member. struct keyword is used to define/create a structure. struct define a new data type which is a collection of different type of data. Syntax
    struct structure_name /tag name
    {
    data_type varialbe1;
    data_type varialbe2;
    . . data_type varialben;
    };
    Note: Don't forget the semicolon }; in the ending line.
    Example
    struct teacher
    { int eid;
    char name[50];
    float salary;
    char subject[20];
    };

    Q No 46 :-Deifine Union

    Ans:-

    Union

    Union is a user defined data type which store heterogeneous/different types data item or element in a single variable. It is a Combination of primitive and derived data type.
    or
    A Union is a collection of one or more data items of different data types, grouped together under a single name.
    Variables inside the Union are called members of Union. Each element of a Union is called a member. union keyword is used to define/create a Union. union define a new data type which is a collection of different type of data. Syntax
    union Union_name /tag name
    {
    data_type varialbe1;
    data_type varialbe2;
    . . data_type varialben;
    };
    Note: Don't forget the semicolon }; in the ending line.
    Example
    union teacher
    { int eid;
    char name[50];
    float salary;
    char subject[20];
    };

    Q No 47 :-Deifine pointer

    Ans:-

    Pointer:

    Pointer is a variable which holds the address of another varialbe. It stores the memory location of anether variable. Pointers can be declared with diffeerent data types. Syntax of pointe declaration

    datatype variable;
    datatype *pintervariable=&varialbe //pointer declarion

    Q No 48 :-Deifine Searching

    Ans:-

    Searching

    An attempt to find the existence of an item in a list of items is called as Searching. It means finding an item in a group of items. For example there many pens of different colors are kept in a box. The task of Finding a pink color pen in the box is called as searching. We can do the searching in different ways.
    In our course of searching we find an element in an array. An Array consists of some elements. The element which we want to search is called as 'Search Key'. The search key may exist in the array or may not exist. If it exists we will return the position of the element else we will return "Element is not found" as result. We discuss two sorting algorithms here
    1. Linear Search
    2. Binary Search

    Q No 49 :Deifine Sorting

    Ans:-

    Sorting

    Arranging items in order is called as sorting. Arranging elements of array or structure in order is called as sorting. There are different types of sorting algorithms are present.
    We discuss the following sorting algorithms.
    1. Selection Sort
    2. Bubble Sort

    Q No 50 :Deifine Functions

    Ans:-

    Functions in C

    Function is collection of instructions used to do specific task. Every c program contains at least one function that is main function. The function can be identified with a name followed by parenthesis. Function consists of three paarts those are
    1. Function Declaration
    2. Function Call
    3. Function Definition

    Q No 51 : Classify Functions based on sisgnature

    Ans:- Based on signature there are 4 types of functions in C. Those are

    1. Functions without return type and without parameters
    2. Functions without return type and with parameters
    3. Functions with return type and without parameters
    4. Functions with return type and with parameters

    Q No 52 : Classify Functions based on parameters

    Ans:- Based on parameter type there are 3 types of functions in C. Those are

    1. Functions with Pass By values
    2. Functions with Pass By variables
    3. Functions with Pass By address or reference