Programming for Problem Solving using C language

CSET3109B.Tech CSE2023-27

Mahatma Gandhi Central University, Bihar

B.Tech Computer Science & Engineering

Semester 2 Examination, 2024

Programming for Problem Solving using C language (CSET3109)

Faculty: Dr. Vipin KumarMaximum Marks: 80

Assessment Questions

Programming for Problem Solving using C language (CSET3109) - 2024

SECTION – A

(Multiple Choice Questions - 10 Marks)

  • 1

    In which year was C language developed?

  • 2

    True statement(s) for C language is

    A) Procedural oriented programming language

    B) General purpose programming language

    C) Structured programming

  • 3

    Consider the following code:

    struct node
    {
        int i;
        float j;
    };
    struct node *s[10];
    

    Which one is the valid statement for the above code?

  • 4

    Consider the following code:

    #include <stdio.h>
    int main()
    {
        int i = 3;
        printf("%d", (++i)++);
        return 0;
    

    What is the output of the above code?

  • 5

    Which is/are the correct syntax to initialize an array in C?

    A. data_type array_name[array_size] = {value1, value2, value3, ...};

    B. data_type array_name[] = {value1, value2, value3, ...};

    C. data_type array_name[array_size] = {};

  • 6

    Consider the following code:

    #include <stdio.h>
    union test { int x; char arr[8]; int y; };
    int main()
    {
        printf("%lu", sizeof(union test));
        return 0;
    }
    

    What is the size of the union based on above program where each integer size has 4 bytes and character has 1 byte.

  • 7

    Consider the following code:

    #include <stdio.h>
    #define PRINT(i, limit) do \\
        { \\
            if (i++ < limit) \\
            { \\
                printf(\"MGCU\\n\"); \\
                continue; \\
            } \\
        } while(0);
    
    int main() {
        int i = 0;
        PRINT(i, 3);
        return 0;
    }
    

    How many times MGCU is printed in the above program ?

  • 8

    Consider the following code:

    #include <stdio.h>
    int main() {
        int i;
        if (printf("0") > 0)
            i = 3;
        else
            i = 5;
    
        printf("%d", i);
        return 0;
    }
    

    What is the output of the above code?

  • 9

    Consider the following code:

    #include <stdio.h>
    int main() {
        int c = 5, no = 10;
        do {
            no /= c;
        } while(c--);
    
        printf(\"%d\\n\", no);
        return 0;
    }
    

    What is the output of above code?

  • 10

    Consider the following code:

    #include<stdio.h>
    int main() {
        int a = 5;
        switch(a)
        {
            default:
                a = 4;
            case 6:
                a--;
            case 5:
                a = a + 1;
            case 1:
                a = a - 1;
        }
        printf(\"%d\\n\", a);
        return 0;
    }
    

    What is the output of the above code?

SECTION – B

(Short Answer Questions- 20 Marks) Attempt ANY FOUR questions out of six questions. Each question carries 05 Marks.

  • 1

    Write the features of C language?

  • 2

    What is the basic data type supported in the C programming language, explain briefly.

  • 3

    What is the scope of the variable? Define the preprocessor in C programming?

  • 4

    Describe the difference between pass by value and pass by reference in C? How can you simulate pass by reference in C?

  • 5

    Create a C program to create a program to implement a simple calculator using switch-case.

  • 6

    Write a C program to find the transpose of a matrix.

SECTION – C

(Long Answer Questions – 30 Marks) Attempt ALL questions having internal choices. The question carries 10 marks.

  • 1

    Answer any ONE of the following

    (a)

    What is the difference between static and dynamic memory allocation in C? Explain with examples and discuss the pros and cons of each.

    OR

    (b)

    Describe the process of compilation in C. What are the different stages involved, and what happens in each stage?

  • 2

    Answer any ONE of the following

    (a)

    Find a sorted array by merging three sorted array using C programming language code.

    OR

    (b)

    Develop a function to find all pairs of integers in an array whose sum is equal to a given target number.

  • 3

    Answer any ONE of the following

    (a)

    Implement a function to find the longest palindromic subarray in a given array.

    OR

    (b)

    Implement a linked list using C programming language where the following task can be performed i.e., adding a node at the last in the linked list, printing the node value existing in the linked list, delete the node after a given node based on specific value.

End of Question Paper