All questions of Programming in C for Computer Science Engineering (CSE) Exam

In C programming language, which of the following type of operators have the highest precedence
  • a)
    Relational operators
  • b)
    Equality operators
  • c)
    Logical operators
  • d)
    Arithmetic operators
Correct answer is option 'D'. Can you explain this answer?

Puja Deshpande answered
Arithmetic operators have the highest precedence in the C programming language.

Precedence refers to the order in which operators are evaluated in an expression. When multiple operators are present in an expression, the operator with higher precedence is evaluated first.

Explanation:
- The arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
- These operators perform mathematical calculations on operands.
- They have the highest precedence because they are fundamental to performing calculations and need to be evaluated before other operations.
- For example, in the expression "2 + 3 * 4", the multiplication operator (*) has higher precedence than the addition operator (+). Therefore, it is evaluated first, resulting in "2 + 12".
- If the precedence of arithmetic operators was lower than other operators, it would lead to incorrect results in mathematical calculations.

Other types of operators:
While arithmetic operators have the highest precedence, it is important to note the precedence of other operators as well:

- Relational operators (e.g., <,>, <=,>=) compare the relationship between two values and return a Boolean value (true or false). They have lower precedence than arithmetic operators.
- Equality operators (e.g., ==, !=) compare if two values are equal or not. They also have lower precedence than arithmetic operators.
- Logical operators (e.g., &&, ||, !) perform logical operations on Boolean values. They have lower precedence than arithmetic operators.

Conclusion:
In C programming language, arithmetic operators have the highest precedence. It is important to understand operator precedence to write correct and predictable code.

What is the output ?
#include <stdio.h>
int main()
{
    int (*ptr)(int ) = fun;
    (*ptr)(3);
    return 0;
}
int fun(int n)
{
  for(;n > 0; n--)
    printf("EduRevQuiz ");
  return 0;
}
  • a)
    EduRevQuiz EduRevQuiz EduRevQuiz
  • b)
    EduRevQuiz EduRevQuiz
  • c)
    Compiler Error
  • d)
    Runtime Error
Correct answer is option 'C'. Can you explain this answer?

The only problem with program is fun is not declared/defined before it is assigned to ptr. The following program works fine and prints "EduRevQuiz EduRevQuiz EduRevQuiz "
int fun(int n);
int main()
{
    // ptr is a pointer to function fun()
    int (*ptr)(int ) = fun;
    // fun() called using pointer 
    (*ptr)(3);
    return 0;
}
int fun(int n)
{
  for(;n > 0; n--)
    printf("EduRevQuiz ");
}

In an expression involving || operator, evaluation
I.   Will be stopped if one of its components evaluates to false
II.  Will be stopped if one of its components evaluates to true
III. Takes place from right to left
IV.  Takes place from left to right
  • a)
    I and II
     
  • b)
    I and III
  • c)
    II and III
  • d)
    II and IV
Correct answer is option 'D'. Can you explain this answer?

Explanation:

The || operator is also known as the logical OR operator. It takes two operands and returns true if at least one of the operands is true. Otherwise, it returns false.

For example:

- true || false evaluates to true
- false || true evaluates to true
- false || false evaluates to false

Now, let's look at the given statements one by one:

I. Will be stopped if one of its components evaluates to false

This statement is incorrect. The || operator does not stop evaluation if one of its components evaluates to false. It only stops evaluation if the first component is true, because in that case, the whole expression is already true.

II. Will be stopped if one of its components evaluates to true

This statement is correct. If the first component of the || operator evaluates to true, the whole expression is already true, and the second component is not evaluated.

III. Takes place from right to left

This statement is partially correct. The || operator evaluates its operands from left to right. However, if the first operand is true, the second operand is not evaluated. Therefore, in some cases, it may seem like the evaluation is happening from right to left.

IV. Takes place from left to right

This statement is partially correct. As mentioned above, the || operator evaluates its operands from left to right. However, if the first operand is true, the second operand is not evaluated.

Therefore, the correct answer is option D: II and IV.

What will be the output of the following program?
void main()
{
      int a, b, c, d;
      a = 3;
      b = 5;
      c = a, b;
      d = (a, b);
      printf("c=%d d=%d", c, d);
}
  • a)
    c=3 d=3
  • b)
    c=3 d=5
  • c)
    c=5 d=3
  • d)
    c=5 d=5
Correct answer is option 'B'. Can you explain this answer?

Nilesh Jain answered
"%d %d %d %d", a, b, c, d);
}

Output:
3 5 3 5

Explanation:
In the statement "c = a, b;", the comma operator evaluates the expression "a" first and assigns its value to "c", then evaluates the expression "b" and discards its value.
In the statement "d = (a, b);", the comma operator evaluates the expression "a" first and discards its value, then evaluates the expression "b" and assigns its value to "d".
Therefore, "c" gets assigned the value of "a" (which is 3) and "d" gets assigned the value of "b" (which is 5). The output of the printf statement will be "3 5 3 5".

In C, what is the meaning of following function prototype with empty parameter list
void fun()
{
   /* .... */
}
  • a)
    Function can only be called without any parameter
  • b)
    Function can be called with any number of parameters of any types
  • c)
    Function can be called with any number of integer parameters.
  • d)
    Function can be called with one integer parameter
Correct answer is option 'B'. Can you explain this answer?

Yash Verma answered
Function Prototype with Empty Parameter List in C

In C, a function prototype with an empty parameter list means that the function can be called with any number of parameters of any types. Let's understand this in detail.

Function Prototype

A function prototype is a declaration that specifies the function name and its parameters, without providing the function definition. It gives the compiler information about the function's return type and the number and types of its parameters.

Empty Parameter List

An empty parameter list in a function prototype means that the function does not have any parameters. In C, an empty parameter list is denoted by leaving the parentheses empty, like `void fun()`. This indicates that the function does not require any arguments.

Meaning of an Empty Parameter List

When a function prototype has an empty parameter list, it means that the function can be called with any number of parameters of any types. This is because the function prototype does not specify any specific parameters, allowing flexibility in the number and types of arguments passed to the function.

Examples

Let's consider an example to understand this concept further:

```
#include

void fun();

int main() {
fun(); // Function call without any parameter
fun(10); // Function call with one integer parameter
fun(10, 20); // Function call with two integer parameters
fun(3.14, "Hello"); // Function call with one double and one string parameter

return 0;
}

void fun() {
printf("Function called\n");
}
```

In the above example, the function `fun` is declared with an empty parameter list in the function prototype. This allows the function to be called without any parameters (`fun()`), with one integer parameter (`fun(10)`), with two integer parameters (`fun(10, 20)`), or with any other combination of parameters.

Conclusion

In C, a function prototype with an empty parameter list indicates that the function can be called with any number of parameters of any types. This provides flexibility in the function call, allowing for different combinations of arguments to be passed to the function.

Which of the following operator takes only integer operands?
  • a)
    +
  • b)
    *
  • c)
    /
  • d)
    %
Correct answer is option 'D'. Can you explain this answer?

Sankar Iyer answered
Integer operands operator

The operator that takes only integer operands is the modulus operator (%).

Explanation

The modulus operator is used to find the remainder of dividing two integers. It takes two integer operands and returns the integer remainder. This means that it cannot be used with non-integer operands such as floating-point numbers or strings.

For example, 7 % 3 = 1 because 7 divided by 3 leaves a remainder of 1.

Other operators like addition, subtraction, multiplication, and division can be used with both integer and non-integer operands, but the modulus operator can only be used with integer operands.

Conclusion

In conclusion, the correct answer is option 'D', the modulus operator (%), which takes only integer operands.

In C, parameters are always 
  • a)
    Passed by value
  • b)
    Passed by reference
  • c)
    Non-pointer variables are passed by value and pointers are passed by reference
  • d)
    Passed by value result
Correct answer is option 'A'. Can you explain this answer?

Mohit Unni answered
Passed by value

In C, parameters are always passed by value. This means that when a function is called and arguments are passed to it, the values of those arguments are copied into the function's parameters. Any changes made to the parameters within the function do not affect the original arguments.

Explanation

When a function is called in C, the values of the arguments are passed to the function. These values are stored in the function's parameters. However, the parameters themselves are separate variables from the original arguments. This means that any changes made to the parameters within the function do not affect the original arguments.

Example

Let's consider a simple example to illustrate this concept:

```c
#include

void modifyValue(int x) {
x = 10; // Modify the parameter
printf("Inside modifyValue: x = %d\n", x);
}

int main() {
int num = 5;

printf("Before calling modifyValue: num = %d\n", num);
modifyValue(num); // Call the function
printf("After calling modifyValue: num = %d\n", num);

return 0;
}
```

Output:
```
Before calling modifyValue: num = 5
Inside modifyValue: x = 10
After calling modifyValue: num = 5
```

In the above example, we have a function `modifyValue()` that takes an integer parameter `x`. When the function is called with the variable `num` as an argument, the value of `num` (which is 5) is copied into `x`. Inside the function, we modify the value of `x` to 10. However, this modification does not affect the original value of `num` outside the function. Thus, when we print the value of `num` after calling the function, it remains unchanged.

Conclusion

In C, parameters are always passed by value. This means that any modifications made to the parameters within a function do not affect the original arguments. This behavior allows for more predictable and controlled manipulation of variables within functions.

What will be the output of the given program?
#include<stdio.h>
void main()
{
    int value1, value2=100, num=100;
    if(value1=value2%5) num=5;
    printf("%d %d %d", num, value1, value2);
}
  • a)
    100 100 100
  • b)
    5 0 20
  • c)
    5 0 100
  • d)
    100 0 100
Correct answer is option 'D'. Can you explain this answer?

Sudhir Patel answered
Expression value2%5 is equal to 0 and this value assigned to value1.
Therefore if condition reduces to if(0) so it fails.
Therefore body of if will not be executed i.e num = 5 will not be assigned.
So at printf num = 100 , value1 = 0 and value2 = 100.

What will be the output of the given program?
#include<stdio.h>
void main()
{
    int a=11,b=5;
    if(a=5) b++;
    printf("%d %d", ++a, b++);
}
  • a)
    12 7
  • b)
    5 6
  • c)
    6  6
  • d)
    11  6
Correct answer is option 'C'. Can you explain this answer?

Explanation:
• The given program initializes two variables, a=11 and b=5.
• In the if statement, a=5 is an assignment operation, not a comparison. It assigns the value 5 to variable a and the condition always evaluates to true.
• So, the statement inside the if block, b++, will be executed. This increments the value of b by 1.
• After the if block, the printf statement prints the values of a and b. The value of a is incremented by 1 using ++a, so a becomes 12.
• The value of b is post-incremented by 1 using b++, so b remains 6.
Therefore, the output of the given program is:
6 6

What is the meaning of using extern before function declaration? For example following function sum is made extern
extern int sum(int x, int y, int z)
{
    return (x + y + z);
}
  • a)
    Function is made globally available
  • b)
    extern means nothing, sum() is same without extern keyword.
  • c)
    Function need not to be declared before its use
  • d)
    Function is made local to the file
Correct answer is option 'B'. Can you explain this answer?

The answer to this question is option 'B' - extern means nothing, sum() is the same without the extern keyword.

When the extern keyword is used before a function declaration, it indicates that the function is defined in a different file. It tells the compiler that the function is declared elsewhere and its definition will be provided at link time.

Here is a detailed explanation of the answer:

1. The extern keyword:
The extern keyword is used to declare a variable or a function that is defined in a separate file or module. It allows the program to use the variable or function even if it is defined in a different source file.

2. Function declaration:
A function declaration is a statement that describes the types of parameters a function accepts and the type of value it returns. It provides the necessary information to the compiler about the function's name, return type, and parameters.

3. The purpose of extern before a function declaration:
When the extern keyword is used before a function declaration, it tells the compiler that the function is defined in a different file. This means that the function's definition will be provided at link time when all the separate object files are combined to create the final executable.

4. The significance of extern in the given example:
In the given example, the function sum() is declared with the extern keyword. This indicates that the function is defined in a different file and its definition will be linked later. However, since the function definition is not provided in the given code snippet, it is not possible to determine the exact behavior or functionality of the sum() function.

5. The absence of extern:
If the extern keyword is not used before the function declaration, it means that the function is defined within the same file. In this case, the function's definition must be present in the same file, either before or after its usage.

In conclusion, when the extern keyword is used before a function declaration, it indicates that the function is defined in a different file. However, in the given example, since the function definition is not provided, the extern keyword has no impact on the function's behavior.

What is the output of given program if user enter "xyz" ?
#include
void main()
{
    float age, AgeInSeconds;
    printf("Enter your age:");
    scanf("%f", &age);
    AgeInSeconds = 365 * 24 * 60 * 60 * age;
    printf("You have lived for %f seconds", AgeInSeconds);
}
  • a)
    Enter your age: xyz You have lived for 0 seconds
  • b)
    Enter your age: xyz You have lived for 0.00000 seconds
  • c)
    Enter your age: xyz "after that program will stop"
  • d)
    Run time error
Correct answer is option 'B'. Can you explain this answer?

Tanishq Malik answered
Explanation:

Input:
- The program asks the user to enter their age.
- The user input is stored in the variable 'age' as a float.

Calculation:
- The program then calculates the total number of seconds the user has lived by multiplying the age in years by the number of seconds in a year (365 * 24 * 60 * 60).

Output:
- Since the user entered "xyz" which is not a valid float value, the scanf function will not be able to convert it to a float.
- As a result, the value of 'age' will remain uninitialized and will have a value of 0.
- Therefore, the calculation for 'AgeInSeconds' will result in 0 seconds.
- The program will then print "You have lived for 0.00000 seconds" as the output.
Therefore, the correct output for the given program when the user enters "xyz" is option 'b) Enter your age: xyz You have lived for 0.00000 seconds'.

Which operator has the lowest priority?
  • a)
    ++
  • b)
    %
  • c)
    +
  • d)
    ||
Correct answer is option 'D'. Can you explain this answer?

Swati Kaur answered
Operator Priority in Programming

In programming, operators are used to perform various operations on variables and values. The order in which the operators are executed is determined by their priority level. The priority level of an operator determines which operation is performed first in an expression.

Lowest Priority Operator

The lowest priority operator is the logical OR operator (||). It is also known as the short-circuit OR operator. This operator is used to evaluate two expressions and returns true if either one of the expressions is true.

The logical OR operator has the lowest priority level among all the operators in programming. This means that it is evaluated last in an expression.

Operator Priority Levels

The priority levels of operators in programming are as follows:

1. Parentheses ()
2. Exponentiation **
3. Multiplication *, division /, and modulo %
4. Addition + and subtraction -
5. Concatenation
6. Comparison operators (==, !=, >, <,>=, < />
7. Logical AND &&
8. Logical OR ||
9. Assignment =, +=, -=, *=, /=, %=, &=, |=, ^=, <=,>>=

Conclusion

In conclusion, the logical OR operator (||) has the lowest priority level among all the operators in programming. It is evaluated last in an expression. It is important to understand the priority levels of operators in programming to ensure that expressions are evaluated correctly.

What will be the value of i and j after execution of following program?
#include<stdio.h>
void main()
{
    int i, j;
    for(i = 0, j = 0; i < 10, j < 20; i++, j++) {
        printf("i=%d j=%d\n", i, j);
    }
}
  • a)
    10 10
  • b)
    10 20
  • c)
    20 20
  • d)
    Run time error
Correct answer is option 'C'. Can you explain this answer?

Nilotpal Das answered
Understanding the For Loop
In the provided code, the for loop initializes variables `i` and `j` and runs a loop based on their conditions.
Code Analysis
- Initialization: `i` and `j` both start at 0.
- Loop Condition: The loop condition uses a comma operator: `i < 10,="" j="" />< 20`.="" />
Comma Operator Behavior
- In C, the comma operator evaluates its first operand (`i < 10`),="" discards="" the="" result,="" and="" then="" evaluates="" and="" returns="" the="" second="" operand="" (`j="" />< />
- This means that the loop will continue as long as `j < 20`,="" regardless="" of="" the="" value="" of="" />
Iteration Details
- Iterations:
- When `i` reaches 10, it stops incrementing further as `i < 10`="" becomes="" />
- However, `j` continues to increment until it reaches 20.
Final Values
- The loop will print pairs `(i, j)` from `(0, 0)` to `(9, 9)`.
- After the loop completes, the values of `i` and `j` will be:
- `i = 10` (as it stops incrementing at this point)
- `j = 20` (as it increments to 20 before the loop condition fails)
Conclusion
The correct answer is option 'b': 10 20.

What is the meaning of using static before function declaration? For example following function sum is made static
static int sum(int x, int y, int z)
{
    return (x + y + z);
}
  • a)
    Static means nothing, sum() is same without static keyword.
  • b)
    Function need not to be declared before its use
  • c)
    Access to static functions is restricted to the file where they are declared
  • d)
    Static functions are made inline
Correct answer is option 'C'. Can you explain this answer?

Static functions in C have different meanings depending on the context. In this case, when the static keyword is used before a function declaration, it means that the function has internal linkage.

Here's an explanation of each option:

a) Static means nothing, sum() is the same without the static keyword.
This option is incorrect. The static keyword does have a specific meaning when used before a function declaration.

b) Function need not to be declared before its use.
This option is incorrect. The static keyword does not affect the requirement of declaring a function before its use. Regardless of whether a function is declared as static or not, it still needs to be declared before its use.

c) Access to static functions is restricted to the file where they are declared.
This option is correct. When a function is declared as static, its scope is limited to the file where it is declared. This means that the function cannot be accessed from other files using external linkage. It provides encapsulation and helps in preventing naming conflicts with functions in other files.

d) Static functions are made inline.
This option is incorrect. The static keyword does not make a function inline. Inline functions are a separate concept and are declared using the inline keyword.

In summary, the correct answer is option 'C': Access to static functions is restricted to the file where they are declared. Static functions have internal linkage and can only be accessed within the same source file where they are declared.

What will be the output of this program on an implementation where int occupies 2 bytes?
#include <stdio.h>
void main()
{
      int i = 3;
      int j;
      j = sizeof(++i + ++i);
      printf("i=%d j=%d", i, j);
}
  • a)
    i=4 j=2
  • b)
    i=3 j=2
  • c)
    i=5 j=2
  • d)
    the behavior is undefined
Correct answer is option 'B'. Can you explain this answer?

Explanation:
- The `sizeof` operator does not actually evaluate the expression, it only determines the size in bytes of the result.
- In the expression `++i + ++i`, the behavior is undefined in C language because it modifies `i` more than once between two sequence points.
- Sequence points in C are points in the execution of a program at which all side effects from previous evaluations are guaranteed to have been performed.
- In this case, the result of `sizeof(++i + ++i)` is 2 because `++i` is evaluated twice, but the value of `i` remains the same as it was before the expression was evaluated.
- Therefore, the value of `i` remains 3 and the value of `j` is 2, so the output will be `i=3 j=2`.
So, the correct answer is option b) i=3 j=2.

Predict the output?
#include <stdio.h>
int main()
{
    void demo();
    void (*fun)();
    fun = demo;
    (*fun)();
    fun();
    return 0;
}
void demo()
{
    printf("EduRevQuiz ");
}
  • a)
    EduRevQuiz
  • b)
    EduRevQuiz EduRevQuiz
  • c)
    Compiler Error
  • d)
    Blank Screen
Correct answer is option 'B'. Can you explain this answer?

Ankita Bose answered


Explanation:

Function Pointers:
- In this program, there is a function pointer `fun` declared and initialized with the address of the function `demo`.
- Function pointers are used to store the address of functions and can be used to call the function indirectly.

Calling the Function using Function Pointer:
- The function `demo` is defined to print "EduRevQuiz".
- The function pointer `fun` is dereferenced and called in two ways:
- `(*fun)();` // Dereferencing the function pointer and calling the function
- `fun();` // Directly calling the function pointer, which is equivalent to the above line

Output:
- So, when the function pointer is called, it will print "EduRevQuiz" twice because the function `demo` is called twice using the function pointer.

Therefore, the output of this program will be:
EduRevQuizEduRevQuiz

Determine output:
void main()

      int i=10; 
      i = !i>14; 
      printf("i=%d", i); 
}
  • a)
    10
  • b)
    14
  • c)
    0
  • d)
    1
Correct answer is option 'C'. Can you explain this answer?

Swati Kaur answered
The output will be 0.

The exclamation mark (!) is the logical NOT operator in C++. It returns the opposite boolean value of the expression. In this case, the expression is the integer i, which has a value of 10.

Since any non-zero integer is considered true in C++, applying the logical NOT operator to it will return false (0). Therefore, the value of i will be set to 0.

Determine output
void main()
{
      int i=0, j=1, k=2, m;
      m = i++ || j++ || k++;
      printf("%d %d %d %d", m, i, j, k);
}
  • a)
    1 1 2 3
  • b)
    1 1 2 2
  • c)
    0 1 2 2
  • d)
    0 1 2 3
Correct answer is option 'B'. Can you explain this answer?

Rashi Mehta answered
"%d", m);}

Output: 1

Explanation:

The logical OR operator (||) returns true (1) if at least one of the operands is true. In this case, i, j, and k are all non-zero values which are considered true in C programming. Therefore, the expression i || j || k evaluates to true, and m is assigned the value of 1. The printf() function then outputs the value of m, which is 1.

What will be the output given program?
#include<stdio.h>
void main()
{
    int i = -10;
    for(;i;printf("%d ", i++));
}
  • a)
    -10 to -1
  • b)
    -10 to infinite
  • c)
    -10 to 0
  • d)
    Complier error
Correct answer is option 'A'. Can you explain this answer?

Rohan Patel answered
Explanation:

Initialization:
- The variable i is initialized to -10.

For Loop:
- In the for loop condition, the expression i is evaluated.
- Since i is a non-zero value (-10), it is considered as true and the loop continues.

Loop Body:
- Inside the loop, the value of i is printed using the printf function.
- Then, i is incremented by 1 using the post-increment operator (i++).

Loop Iteration:
- The loop continues to run as long as the condition i is true.
- Since i is a non-zero value, the loop continues to print the value of i.

Output:
- The loop will continue to print the values of i starting from -10 and incrementing by 1 each time.
- The output will be: -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
Therefore, the correct answer is option 'a' which states that the output will be -10 to -1.

Output of following program?
#include<stdio.h>
void dynamic(int s, ...)
{
    printf("%d ", s);
}
int main()
{
    dynamic(2, 4, 6, 8);
    dynamic(3, 6, 9);
    return 0;
}
  • a)
    2  3
  • b)
    4  3
  • c)
    3  2
  • d)
    Compiler Error
Correct answer is option 'A'. Can you explain this answer?

Explanation:

Main Function:
- The main function calls the `dynamic` function twice with different numbers of arguments.

Dynamic Function:
- The `dynamic` function takes an integer `s` and an ellipsis (`...`) representing a variable number of arguments.
- Inside the `dynamic` function, it prints the value of `s`.

Output:
- In the first call to `dynamic(2, 4, 6, 8)`, the integer `s` is 2, so it prints `2`.
- In the second call to `dynamic(3, 6, 9)`, the integer `s` is 3, so it prints `3`.
Therefore, the output of the program is:
2 3

Output of following program?
#include <stdio.h>
int main()
{
    int i = 5;
    printf("%d %d %d", i++, i++, i++);
    return 0;
}
  • a)
    7  6  5
  • b)
    5  6  7
  • c)
    7  7  7
  • d)
    Compiler Dependent
Correct answer is option 'D'. Can you explain this answer?

Sudhir Patel answered
When parameters are passed to a function, the value of every parameter is evaluated before being passed to the function. What is the order of evaluation of parameters - left-to-right or right-to-left? If evaluation order is left-to-right, then output should be 5 6 7 and if the evaluation order is right-to-left, then output should be 7 6 5. Unfortunately, there is no fixed order defined by C standard. A compiler may choose to evaluate either from left-to-right. So the output is compiler dependent.

#include <stdio.h>
int main()
{
  printf("%d", main);  
  return 0;
}
  • a)
    Address of main function
  • b)
    Compiler Error
  • c)
    Runtime Error
  • d)
    Some random value
Correct answer is option 'A'. Can you explain this answer?

Sudhir Patel answered
Name of the function is actually a pointer variable to the function and prints the address of the function. Symbol table is implemented like this.
struct
{
   char *name;
   int (*funcptr)();
}
symtab[] = {
   "func", func,
   "anotherfunc", anotherfunc,
};

Which of the following comments about the ++ operator are correct?
  • a)
    It is a unary operator
  • b)
    The operand can come before or after the operator
  • c)
    It cannot be applied to an expression
  • d)
    All of the above
Correct answer is option 'D'. Can you explain this answer?

Bijoy Joshi answered
Explanation:

The & operator in programming is used to perform a bitwise AND operation on two integers. It compares the corresponding bits of the two numbers and returns a new number where each bit is set to 1 only if both bits were 1 in the original numbers. Here are the correct comments about the & operator:

Unary Operator:
- A unary operator is an operator that operates on a single operand or variable. It only requires one operand to perform the operation.
- The & operator is not a unary operator. It is a binary operator that requires two operands.

Operand Order:
- The order of the operands in a binary operation can affect the result of the operation.
- For the & operator, the order of the operands does not matter. The result will be the same regardless of which operand comes first.

Expression Application:
- An expression is a combination of one or more values, constants, variables, operators, and functions that are evaluated to produce a result.
- The & operator can be applied to expressions as long as the expressions evaluate to integers.

Conclusion:
- The correct comments about the & operator are:
- It is a binary operator
- The order of the operands does not matter
- It can be applied to expressions that evaluate to integers
- Therefore, option 'D' is the correct answer.

Chapter doubts & questions for Programming in C - Programming and Data Structures 2025 is part of Computer Science Engineering (CSE) exam preparation. The chapters have been prepared according to the Computer Science Engineering (CSE) exam syllabus. The Chapter doubts & questions, notes, tests & MCQs are made for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests here.

Chapter doubts & questions of Programming in C - Programming and Data Structures in English & Hindi are available as part of Computer Science Engineering (CSE) exam. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.

Signup to see your scores go up within 7 days!

Study with 1000+ FREE Docs, Videos & Tests
10M+ students study on EduRev