Aspire's Library

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

WB JECA MCA Previous Year Questions (PYQs)

WB JECA MCA C Programming Language PYQ


WB JECA MCA PYQ
What is the output of the following code snippet?  
#include <stdio.h>
main() {
int x = 65, *p = &x;
void *q = p;
char *r = q;
printf("%c", *r);
}

(A) $A$  
(B) $Z$  
(C) $65$  
(D) None of the above  





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Step 1: Initialization

$x = 65$
In ASCII, $65 \equiv A$

Step 2: Pointer flow
$p = \&x \;\; \rightarrow$ pointer to integer
$q = p \;\; \rightarrow$ void pointer
$r = q \;\; \rightarrow$ typecast to char pointer

Step 3: Dereferencing
Since r is char*, it reads 1 byte.
The value stored = $65$

Step 4: Printing
printf("%c", *r); prints character with ASCII $65$.
Hence, the output is:

$\; \boxed{A} \;$

Correct Answer: (A) 


WB JECA MCA PYQ
What is the output of the following C-program?
#include
int main() { 
const int a=10; 
printf("%d", +a); 
return 0; 
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

The constant a=10. Unary +a does not increment, it only returns the same value.
So, output = 10.
Answer = (B) 10

WB JECA MCA PYQ
How can you display a list of all files including the hidden files?





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

In Linux/Unix, hidden files are shown using ls -a.
Answer = (C) ls -a

WB JECA MCA PYQ
Which C keyword is used to extend the visibility of variables?





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

The extern keyword is used in C to extend variable visibility across multiple files.
Answer (C) extern

WB JECA MCA PYQ
What is the output of the following C-program?\n#include\n#define CUBE(x) (x*x*x)\nint main() { int a, b=3; a = CUBE(b++); printf("%d, %d\n", a, b); return 0; }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution:
- Macro expansion: CUBE(b++) → (b++ * b++ * b++).
- This causes multiple side effects → undefined behavior.
- Most compilers treat this as error/undefined.
Answer = (D) Error

WB JECA MCA PYQ
What is the output of following C code? int main(){ int x=2, y=1; x *= x + y; printf("%d", x); }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: x *= x + y means x = x * (x + y)2 * (2 + 1) = 6.
Answer: (D) 6

WB JECA MCA PYQ
What is the output of the following code snippet? #include int main(){ int x; x = 5 > 8 ? 10 : 1 != 2 < 5 ? 20 : 30; printf("%d", x); return 0; }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: 5>8 is false ⇒ evaluate 1 != 2 < 5 ? 20 : 30.
Relational before != : 2<5 ⇒ 1. Then 1 != 1 ⇒ false ⇒ choose 30.
Answer: (D) 30

WB JECA MCA PYQ
What will be the output of the C code? #include int main(){ int a=1; if(a--) printf("True"); if(a++) printf("False"); }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: First if(a--) uses 1 (true) then decrements to 0 ⇒ prints "True".
Second if(a++) tests 0 (false) then increments to 1 ⇒ no print.
Answer: (A) True

WB JECA MCA PYQ
What is the output of the C-program? int main(){ int i=0; int x=i++; int y=++i; printf("%d %d", x,y); }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: The snippet shown misses a declaration of y (outside initialization), so it will not compile. Hence, it gives a compilation error.
Answer: (D) compile error

WB JECA MCA PYQ
What is the output of the C-program? int main(){ int i=0; while(i=0) printf("True"); printf("False"); }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: while(i=0) assigns 0 ⇒ condition false ⇒ loop not executed. Prints "False".
Answer: (C) False

WB JECA MCA PYQ
What is the output of the following code snippet? int main(){ int i,k=5; if(i=k){ printf("YES"); } else { printf("NO"); } }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2024 PYQ

Solution

Solution: if(i=k) assigns 5 to i ⇒ condition true ⇒ executes if-block ⇒ prints "YES".
Answer: (B) YES

WB JECA MCA PYQ
What is the output of the following program ? 
#include void main ( ) 
 { 
 int a = 40; float b; 
 b = ++a; 
 printf(“%d, %f ”, a, ++b); 
 }





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution


WB JECA MCA PYQ

What is the output of the following C program?

#include <stdio.h>
void main(){
  int a = -7;
  float b;
  b = a++;
  printf("%d, %f ", a, ++b);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The statement b = a++; assigns the current value of a (−7) to b and then increments a to −6. Later, ++b increments b from −7 to −6 before printing. $$ a = -6,\quad b = -6.000000 $$

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
void main(){
  int i = -1;
  printf("sizeof(i) = %d", sizeof(i));
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The operator sizeof gives the size of the type in bytes, not the value. On most 32-bit and 64-bit systems, sizeof(int) is 4. $$ \text{Output: } \texttt{sizeof(i) = 4} $$

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
void main(){
  int x = -1, y = 1, z = 0;
  if(x && y++ && z)
    ++x, y++, --z;
  printf("%d, %d, %d", x++, y++, z++);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: In the condition x && y++ && z, since z = 0, the logical AND short-circuits and the body of the if is not executed. However, y++ is evaluated before the short-circuit, so y becomes 2. Values before printing: $$ x = -1,\ y = 2,\ z = 0 $$ So the program prints: $$ (-1,\ 2,\ 0) $$

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
enum colors{RED, BROWN, ORANGE};
void main(){
  printf("%ld..%f..%d", RED, BROWN, ORANGE);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The format specifiers do not match the data types (%f is used for int). This causes undefined behavior. The program may compile, but the output is not reliable. Correct choice: None of these.

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
void main(){
  char M = 'M';
  printf("%d, %c", M, M);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The character 'M' has an ASCII value of 77. So printing with %d shows 77, and %c shows M. $$ \text{Output: } 77,\ M $$

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
void main(){
  int i = -9;
  printf("%d %d %d", i++, ++i, ++i);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Ek hi expression me variable i par multiple modifications → C standard me undefined behavior.
Isliye koi fixed output/compile error guarantee nahi. Sahi option: None of these.

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
void main(){
  int **ptr;
  int temp = 65;
  ptr[0] = &temp;
  printf("%d", ptr[0][0]);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The pointer ptr is uninitialized, so it does not point to valid memory. When the code tries to access ptr[0], it attempts to dereference an invalid location. This leads to undefined behavior, and in most cases results in a segmentation fault.

WB JECA MCA PYQ

What is the output?

#include <stdio.h>
#include <stdlib.h>
void main(){
  int *ptr;
  ptr = (int*) calloc(3, sizeof(int));
  ptr[2] = 30;
  printf("%d", *ptr);
  free(ptr);
}





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Explanation: The function calloc initializes all allocated memory blocks with zero. So ptr[0] is initialized to 0. The statement *ptr is equivalent to ptr[0]. $$ \text{Output: } 0 $$

WB JECA MCA PYQ
25.What is the output of the following program ?  include <iostream>  using namespace std;  int addition (int a, int b)  {   return a+b;  }  double addition (double a, double b)  {   return a+b;  }  int main ()  {   cout<< addition (35,20) << “;”;   cout<< addition (34.1,12.7);   return 0;  } 





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

The given program defines two overloaded functions `addition`:  
1. `int addition(int a, int b)` → returns integer sum  
2. `double addition(double a, double b)` → returns double sum  

In `main()`:
- `addition(35,20)` calls the integer version → 35 + 20 = 55  
- `addition(34.1,12.7)` calls the double version → 34.1 + 12.7 = 46.8  

Therefore, the output is:  
55;46.8


WB JECA MCA PYQ
26.What is the output of the following program ?  #include <iostream>  using namespace std;  template <class C1, class C2>  bool is_equal (C1 var1, C2 var2)  {   return (var1 = = var2);  }  int main ()  {   if (is_equal(10,10.0))    cout<< “Equal”;   else    cout<< “Not equal”;   return 0;  } 





Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

The function `is_equal` is a template that compares two variables of possibly different types.  
In `main()`, we call `is_equal(10, 10.0)`.  

- `10` is an integer (int).  
- `10.0` is a double.  
C++ allows implicit type conversion during comparison.  
So, `10 == 10.0` evaluates to `true`.  

Therefore, the condition in the `if` statement is true, and the output will be:  

Equal


WB JECA MCA PYQ
26.What is the output of the following program ?

#include <iostream>
using namespace std;

int main() 
{
    int var = 0;
    while (var < 10) 
    {
        cout << var << " ";
        var++;
    }
    cout << var;
    return 0;
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Output:
0 1 2 3 4 5 6 7 8 9 10

Explanation:

  • The variable var starts at 0.

  • The while (var < 10) loop prints 0 1 2 3 4 5 6 7 8 9 with spaces.

  • When var reaches 10, the loop stops.

  • After the loop, cout << var; prints 10.

    Final output:

    0 1 2 3 4 5 6 7 8 9 10


WB JECA MCA PYQ
What is the output of the following program ?
#include <iostream>
using namespace std;
struct demo
{
    int var;
};
int main()
{
    demo str;
    demo *ptr;

    str.var = 100;
    ptr = &str;
    cout << ptr->var;
    return 0;
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

Output:
100
Explanation:

str.var = 100; assigns 100 to the structure variable.

ptr = &str; makes the pointer point to str.

ptr->var accesses the member var of structure str via pointer.

Hence it prints 100.


WB JECA MCA PYQ
29.What is the output of the following program ?
#include <iostream>
using namespace std;
int main ()
{
    int c1 = 10;
    int c2 = 20;
    {
        int c1;
        c1 = 50;
        c2 = 50;
        cout << "c1= " << c1 << ", c2=" << c2;
    }
    cout << ", c1= " << c1 << ", c2=" << c2;
    return 0;
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

  • Output:
    c1= 50, c2=50, c1= 10, c2=50
    Explanation:

    Outer c1 = 10, c2 = 20.

    Inside the inner block, a new local c1 is declared (shadowing outer c1).

    Inner c1 = 50, and c2 (outer one) is updated to 50.

    First cout prints → c1= 50, c2=50.

    After the block ends, inner c1 is destroyed. Outer c1 remains 10, while outer c2 is 50.

    Second cout prints → , c1= 10, c2=50.

    ? Final output: c1= 50, c2=50, c1= 10, c2=50.


WB JECA MCA PYQ
30.What is the output of the following program ?
#include <iostream>
using namespace std;

class Demo {
public:
    static int count;
    Demo() { count++; }
};

int Demo::count = 0;

int main() {
    Demo var1;
    Demo var2[5];
    cout << var1.count;
    return 0;
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

  • Explanation:

    • int Demo::count = 0; initializes the static variable count to 0.

    • Demo var1; → constructor is called once → count = 1.

    • Demo var2[5]; → constructor is called 5 times (for each element in the array) → count = 6.

    • Since count is static, it is shared among all objects.

    • Finally, cout << var1.count; prints 6.

    ? Correct answer: (A) 6


WB JECA MCA PYQ
31.What is the output of the following program ?
#include <iostream>
using namespace std;

void print();
int main()
{
    int var = 0;
    var = print();
    cout << var;
    return 0;
}

void print()
{
    cout << "Hi";
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

  • Explanation:

    • print() is declared as void print().

    • In main(), the statement var = print(); tries to assign the return value of print() to an int variable.

    • But since print() has no return value (void), this causes a compile-time error.

    Hence, the program does not compile.


WB JECA MCA PYQ
32.What is the output of the following program ?
#include <iostream>
using namespace std;

int main()
{
    int var = 2;
    do
    {
        cout << var;
    } while (var--);
    return 0;
}






Go to Discussion

WB JECA MCA Previous Year PYQ WB JECA MCA JECA MCA 2023 PYQ

Solution

  • Explanation:

    • Initially var = 2.

    • First iteration: prints 2, then var-- makes var = 1.

    • Second iteration: prints 1, then var-- makes var = 0.

    • Third iteration: prints 0, then var-- makes var = -1. Condition fails and loop exits.

    So output is:



WB JECA MCA


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

Click Here to
View More

WB JECA MCA


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

Click Here to
View More

Ask Your Question or Put Your Review.

loading...