Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations

Jamia Millia Islamia Previous Year Questions (PYQs)

Jamia Millia Islamia C Programming Language PYQ


Jamia Millia Islamia PYQ
Which of the following errors can a compiler check?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2024 PYQ

Solution

A compiler detects Syntax Errors, i.e., grammatical mistakes in code.

Jamia Millia Islamia PYQ
What will be values for $a$ and $c$ after execution of the following code if $a$ is $10$, $b$ is $5$, and $c$ is $10$? if ((a > b) && (a <= c)) a = a + 1; else c = c + 1;





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2024 PYQ

Solution

$a>b$ is $10>5$ (true) and $a\le c$ is $10\le10$ (true). Condition is true $\Rightarrow$ execute $a=a+1 \Rightarrow a=11$, $c$ unchanged $=10$.

Jamia Millia Islamia PYQ
What is meant by 'a' in the following C file operation? fp = fopen("Random.txt", "a");





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2024 PYQ

Solution

In C programming, the mode 'a' in the fopen() function is used to open a file in append mode, which allows new data to be added to the end of the file without deleting existing content.

Jamia Millia Islamia PYQ
The size of a union is determined by the size of the ________.





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2024 PYQ

Solution

The union in C shares the same memory space among all members. Hence, its size equals the size of its largest member.

Jamia Millia Islamia PYQ
Which of the following languages is case sensitive?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2021 PYQ

Solution

C distinguishes uppercase/lowercase identifiers.

Jamia Millia Islamia PYQ
C is a:





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2021 PYQ

Solution

C is often called a “middle-level” language — a high-level language that also supports low-level features (pointers, bitwise ops, etc.).

Jamia Millia Islamia PYQ
The minimum number of temporary variables needed to swap the contents of two variables is:





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2021 PYQ

Solution

Can swap in-place using XOR or +/− without any temp.

Jamia Millia Islamia PYQ
Consider the following C language declarations & statements. Which statement is erroneous? float f1 = 9.9; float f2 = 66; const float *ptrF1; float * const ptrF2 = &f2; ptrF1 = &f1; ptrF2++; ptrF1++;





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

- `const float *ptrF1;` → pointer to constant float, can move pointer, not modify value. - `float * const ptrF2 = &f2;` → constant pointer to float, cannot change address, but can modify value. - Statement `ptrF2++` tries to move a **constant pointer**, which is **not allowed**. Hence, `ptrF2++` is **erroneous**.

Jamia Millia Islamia PYQ
What will be output of following statements? int n1 = 3, n2 = 6, a; printf("(n1 ^ n2) + (a ^ a) = %d", (n1 ^ n2) + (a ^ a));





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: Operator `^` is **bitwise XOR**. $n1 = 3 \Rightarrow 011_2$ $n2 = 6 \Rightarrow 110_2$ $n1 \oplus n2 = 101_2 = 5$ Variable `a` is declared but **not initialized**. Using an uninitialized variable in expression `(a ^ a)` causes **undefined behavior**. Hence, the program compiles but produces a **run-time error or unpredictable result**.

Jamia Millia Islamia PYQ
What will be output of following statements? char ch; ch = 130; printf("\nvalue of ch=%d", ch);





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: In C, the range of `char` is from $-128$ to $127$. When we assign $130$ to a `char`, it overflows: $130 - 256 = -126$ Thus the value stored in `ch` is $-126$. Output: value of ch = -126

Jamia Millia Islamia PYQ
What is the output of the following C code segment?

int i;
for(i = 0; i <= 2; i++)
{
    switch(i)
    {
        case 1: printf("%2d", i);
        case 2: printf("%2d", i); continue;
        default: printf("%2d", i);
    }
}





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution:

Let’s analyze iteration by iteration —

**Iteration 1:** `i = 0`  
→ `switch(0)` → goes to `default:` → prints `0`.

**Iteration 2:** `i = 1`  
→ executes `case 1:` → prints `1`  
→ no `break`, so it falls through to `case 2:` → prints `1`  
→ encounters `continue;` → skips remaining statements in the `for` loop body and proceeds to next iteration.

**Iteration 3:** `i = 2`  
→ executes `case 2:` → prints `2`  
→ `continue;` moves control to the next iteration, but loop ends because `i <= 2` condition fails.

Final output:  
`0 1 1 2`




Jamia Millia Islamia PYQ
 What is the output of the following C program?

int main()
{
    char ch = 'A';
    int x = 97;
    int y = sizeof(++x);
    printf("\nx is %d", x);
    while (ch <= 'F')
    {
        switch (ch)
        {
            case 'A':
            case 'B':
            case 'C':
            case 'D': ch++; break;
            case 'E':
            case 'F': ch++;
        }
        putchar(ch);
    }
    return 0;
}






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution:

1️⃣ `int y = sizeof(++x);`  
→ `sizeof` is a compile-time operator, so `++x` is **not evaluated**.  
Hence, `x` remains unchanged (`x = 97`).

2️⃣ `printf("\nx is %d", x);`  
→ prints: `x is 97`

3️⃣ Loop execution:

| ch  | switch(ch) executes | putchar(ch) prints | next value of ch |
|------|----------------------|--------------------|------------------|
| 'A'  | falls to case 'D' → ch++ → break | prints `'B'` | 'B' |
| 'B'  | falls to case 'D' → ch++ → break | prints `'C'` | 'C' |
| 'C'  | falls to case 'D' → ch++ → break | prints `'D'` | 'D' |
| 'D'  | case 'D' → ch++ → break | prints `'E'` | 'E' |
| 'E'  | case 'E' → fall through to case 'F' → ch++ | prints `'F'` | 'F' |
| 'F'  | case 'F' → ch++ | prints `'G'` | 'G' (loop ends) |

Output sequence = `x is 97 BCDEFG`




Jamia Millia Islamia PYQ
What is the output of following C program?

void e(int x)
{
    if (x > 0)
    {
        e(- -x);
        printf("%2d", x);
        e(- -x);
    }
}

int main()
{
    e(3);
    return 0;
}





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution:

In C, the tokens `- -x` are parsed as two unary minuses with a space, i.e. $-(-x)=x$.
So both recursive calls are `e(x)`, not `e(--x)`.

For `x=3`, the function calls itself **with the same positive value** forever:
`e(3) → e(3) → e(3) → ...` and never reaches a base case.

This causes infinite recursion (stack overflow) at run time.




Jamia Millia Islamia PYQ
Minimum & Maximum range of values for ‘float’ data type in C is:





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

In standard C (IEEE-754 single precision), the approximate range of a `float` is from $1.17 \times 10^{-37}$ to $3.4 \times 10^{38}$.

Jamia Millia Islamia PYQ
Which out of these is NOT valid for C language?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: When a local variable has the same name as a global variable, the **local variable overrides** (takes precedence over) the global one inside its block. Thus (C) is **invalid** for C.

Jamia Millia Islamia PYQ
The output of following C language statement is: printf("\nhello" + 3);





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: String: "\nhello" Character positions: 0:'\n' 1:'h' 2:'e' 3:'l' 4:'l' 5:'o' → "\nhello" + 3 points to index 3, i.e., `"llo"` Hence it prints “llo”.

Jamia Millia Islamia PYQ
Give output of following C code:

int count(unsigned x)
{
    int b;
    for (b = 0; x != 0; x >>= 1)
        if (x & 1)
            b++;
    return b;
}

int main()
{
    unsigned int a = 3;
    printf("%d", count(a));
    return 0;
}






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

```ruby Solution: The function `count()` counts number of 1-bits in the binary representation of `x`. For `a = 3` Binary of 3 = `11` → Number of 1 bits = 2 Hence output = 2.

Jamia Millia Islamia PYQ
What is the data type of the following expression:  
expr₁ ? expr₂ : expr₃  
if expr₁ is of type float & expr₂ is of type int.





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: In the **ternary operator** `(expr₁ ? expr₂ : expr₃)`, the **data type of result** is the **common type** of `expr₂` and `expr₃`. Here, - `expr₁` → condition (float type, irrelevant for result type) - `expr₂` → int - `expr₃` → (not specified but implied same as expr₂ type logic) When int and float are combined → **result type = float** (implicit type conversion).

Jamia Millia Islamia PYQ
 Which operator out of these has got the highest precedence?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: Operator precedence (from high to low in C): `[]` > `<` > `?:` > `,` Therefore, the highest precedence among these is **array subscript `[ ]`**.

Jamia Millia Islamia PYQ
Which operator out of these has left to right associativity?






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Operator associativity in C: - Most unary operators (!, ++, --, sizeof, etc.) → **Right to Left** - Conditional (`?:`) → **Right to Left** - Comma operator (`,`) → **Left to Right** Hence, only the **comma operator** has **left-to-right** associativity.

Jamia Millia Islamia PYQ
Consider the following code segment:

if (n > 0)
    for (i = 0; i < 3; i++)
        if (array[i] > 0)
            printf("%d\n", array[i]);
        else
            printf("\n n is negative\n");

Here, ‘else’ is paired with which ‘if’?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: In C, **“else” is always paired with the nearest unmatched “if”** (no braces rule). Here: - The inner `if (array[i] > 0)` is the **nearest unmatched `if`** before `else`. So, the `else` is paired with the **second (inner)** `if`.

Jamia Millia Islamia PYQ
For this kind of declaration of main() function in a C program ‘copy.C’:

int main(int argc, char *argv[]) { }

and this call of main function at command prompt:
C:\tc\bin>copy file1 file2 file3

What will be the value passed in parameter argc?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: The **argc (argument count)** includes the program name itself. So the arguments are: 1️⃣ "copy" (program name) 2️⃣ "file1" 3️⃣ "file2" 4️⃣ "file3" Thus, total arguments = 4.

Jamia Millia Islamia PYQ
What is the correct file mode that opens preexisting file in read and write mode?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: - `"r+b"` or `"rb+"` → open **existing file** for both reading and writing (no truncation). - `"w+b"` or `"wb+"` → open file for reading and writing but **creates/truncates** file. - `"ab"` → append binary mode. Hence, the correct mode for **existing file in read-write** is `"r+b"`.

Jamia Millia Islamia PYQ
Which C expression correctly represents this statement: “It decrements pointer p before fetching the character that p points to.”





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: - `p--` → post-decrement (use then decrement) - `--p` → pre-decrement (decrement then use) Here, we need to **decrement p first**, then fetch the value it points to. Hence, correct expression: `*--p`

Jamia Millia Islamia PYQ
How many times this statement will execute: for (; *s == *t && *t != '\0'; s++, t++) if both character pointers ‘s’ and ‘t’ point to the same string “abc”.





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: String = "abc" → characters: a, b, c, '\0' Loop condition: - Iteration 1: *s = 'a', *t = 'a' → true - Iteration 2: *s = 'b', *t = 'b' → true - Iteration 3: *s = 'c', *t = 'c' → true - Iteration 4: *s = '\0', *t = '\0' → fails because *t != '\0' → false Hence, loop executes **3 times**.

Jamia Millia Islamia PYQ
Which out of these statements is NOT true:





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: All three statements (A), (B), and (C) are correct according to C language behavior. Hence, there is **no incorrect statement**.

Jamia Millia Islamia PYQ
Which out of these is NOT the keyword C99 has added in addition to 32 keywords defined by ANSI C?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: C99 added these new keywords: - `_Bool` - `inline` - `restrict` - `_Complex` - `_Imaginary` `register` is an **old ANSI C keyword**, not added in C99.

Jamia Millia Islamia PYQ
Which out of these is NOT a valid C version?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2023 PYQ

Solution

Solution: Valid C versions are: - C89 (ANSI standard, 1989) - C90 (ISO standard, 1990) - C99, C11, C17, and C23 There is **no version called C2007 or CIX**.

Jamia Millia Islamia PYQ
What will be the output of the statement printf(3+"goodbye");





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

"goodbye" is a char array; 3 + "goodbye" points to the 4th char → "dbye".

Jamia Millia Islamia PYQ
What will be the output of the statements? 
int i = 1, j;
j = i-- - -2;
printf("%d", j);






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

i-- uses the old value 1, then i becomes 0. Expression is 1 - (-2) = 3.

Jamia Millia Islamia PYQ
What will be output of following statements?
int i = 1, j;
j = --i - 2;
printf("%d", j);






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

i = 1 → --i = 0 → j = 0 - 2 = -2

Jamia Millia Islamia PYQ
What is the output of following C Program?
#include <stdio.h>
int main()
{
    char grade[] = {'A','B','C'};
    printf("GRADE=%c, ", *grade);
    printf("GRADE=%d", grade);
    return 0;
}






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

*grade = 'A', grade = base address of array Output: GRADE=A, GRADE=some address of array

Jamia Millia Islamia PYQ
Which one is not a reserve keyword in C Language?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

main (function name, not a keyword).

Jamia Millia Islamia PYQ
What is the output of following C program:

int main(){
  int a[3]={10,12,14};
  a[1]=20; int i=0;
  while(i<3){ printf("%d ", a[i]); i++; }
  return 0;
}






Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

main (function name, not a keyword).

Jamia Millia Islamia PYQ
Prototype of a function means ____





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

(interpreting “contains 1” as **exactly one** ‘1’, repetitions allowed):** Case-1: ‘1’ in the thousand’s place → remaining $3$ places from $\{0,\dots,7\}\setminus\{1\}$ with repetition: $7^3=343$ ways. Case-2: ‘1’ in any one of the last three places ($3$ choices). Thousand’s place from $\{2,\dots,7\}$ ($6$ ways). Remaining two places from $\{0,\dots,7\}\setminus\{1\}$ with repetition: $7^2=49$ ways. Total $=343+3\cdot6\cdot49=343+882

Jamia Millia Islamia PYQ
Far pointer can access ____





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

(interpreting “contains 1” as **exactly one** ‘1’, repetitions allowed):** Case-1: ‘1’ in the thousand’s place → remaining $3$ places from $\{0,\dots,7\}\setminus\{1\}$ with repetition: $7^3=343$ ways. Case-2: ‘1’ in any one of the last three places ($3$ choices). Thousand’s place from $\{2,\dots,7\}$ ($6$ ways). Remaining two places from $\{0,\dots,7\}\setminus\{1\}$ with repetition: $7^2=49$ ways. Total $=343+3\cdot6\cdot49=343+882

Jamia Millia Islamia PYQ
A pointer that is pointing to NOTHING is called ____  





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

Null pointer

Jamia Millia Islamia PYQ
What is the similarity between a structure, union and enumeration?  





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

 All of them let you define new data types

Jamia Millia Islamia PYQ
 How will you free the allocated memory?  





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

 All of them let you define new data types

Jamia Millia Islamia PYQ
Which bitwise operator is suitable for turning off a particular bit in a number?





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2022 PYQ

Solution

Use bitwise AND with a mask having 0 at that bit.

Jamia Millia Islamia PYQ
Consider the following lists, and then select the correct option after matching them. $\begin{array}{|c|l|c|l|} \hline \textbf{List–I} & & \textbf{List–II} & \\ \hline 1. & \text{Procedural Oriented Language} & P. & \text{COBOL} \\ \hline 2. & \text{Object Oriented Language} & Q. & \text{HTML} \\ \hline 3. & \text{Business Oriented Language} & R. & \text{C++} \\ \hline 4. & \text{Web Page} & S. & \text{Pascal} \\ \hline \end{array}$





Go to Discussion

Jamia Millia Islamia Previous Year PYQ Jamia Millia Islamia JAMIA MILLIA ISLAMIA MCA 2019 PYQ

Solution

Procedural Oriented → Pascal $(1,S)$ Object Oriented → C++ $(2,R)$ Business Oriented → COBOL $(3,P)$ Web Page → HTML $(4,Q)$ Correct match: $(1,S), (2,R), (3,P), (4,Q)$


Jamia Millia Islamia


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Jamia Millia Islamia


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...