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 C programming, what is the purpose of using 'short' with the 'int' data type?

  • 2

    Consider the following code snippet:

    #include <stdio.h>
    void main() {
        float value;
        printf("Enter a value between 1 and 2: ");
        scanf("%f", &value);
        switch (value) {
            case 1:
                printf("One");
                break;
            case 2:
                printf("Two");
                break;
        }
    }
    
  • 3

    Consider the following code snippet:

    #include <stdio.h>
    int main() {
        if (printf("Hello") && printf(" World"))
            printf(" - Printed");
        else
            printf(" - Not Printed");
        return 0;
    }
    

    What is output of the given C code?

  • 4

    Consider the following code snippet:

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

    What is the output of the code?

  • 5

    Which of the following is responsible for converting the source code into object code?

SECTION – B

(Short Answer Questions- 5 Marks) Attempt ANY TWO questions out of three questions. Each question carries 2.5 Marks.

  • 1

    The C programming language has several essential features that distinguish it from other programming languages. Describe the fundamental data types and their cyclic nature, if applicable.

  • 2

    Explain the different types of errors that may take place in C programming, providing appropriate instances as illustrations.

  • 3

    Write a C program to generate random numbers without using the rand() function. Explain the approach you would use to achieve this functionality.

SECTION – C

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

  • 1

    Answer any ONE of the following

    (a)

    Write a C programming code to find the number of palidrome exist in given number digits.

    OR

    (b)

    Write a C programming code to function as a basic calculator with operations such as addition, subtraction, multiplication, division, and remainder. Additionally, the programme should end dependent on user input. Otherwise, the loop should continue until the following operation.

  • 2

    Answer any ONE of the following

    (a)

    Write a C programming code to print the given pattern X, where the height of the triangle will be provided by the user.

    Question 2(a) diagram

    OR

    (b)

    Write a C programming code to print the given pattern, where the height of 'S' letter will be provided by the user.

    Question 2(b) diagram
End of Question Paper