Search Header Logo

C Language

Authored by Sahitya Satya

Computers

University

Used 14+ times

C Language
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

#include <stdio.h>  

void change(int,int);  

int main()  

{  

    int a=15,b=16;  

    change(a,b); 

    printf("Value of a is: %d",a);  

    printf("\n");  

    printf("Value of b is: %d",b);  

    return 0;  

}  

void change(int x,int y)  

{  

    x=13;  

    y=17;  

What will be the output:-

Value of a is: 15 Value of b is: 16

Value of a is: 13 Value of b is: 17

Value of a is: 16 Value of b is: 15

Value of a is: 17 Value of b is: 13

2.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

Correct way to initialize an array in C programming Language is:-

int num[6] = { 1, 2, 3, 4, 5};

int num[6] = { 1, 2, 3, 16, 25, 45, 9 };

int a={};

int x{3}={2,3,4};

3.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

The correct output of given code snippet is:-

#include<stdio.h>

void main()

{

int a[5]= {1,2,1,4,9};

int i, j, k;

i= ++a[1];

j= a[1]++;

k= a[1++];

printf("%d, %d, %d", i, j, k);

}

3, 4, 1

2, 2, 9

4, 3, 4

3, 3, 1

4.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

The correct Code to swap two numbers in C language without using a third variable is:-

#include<stdio.h>

int main()

{

int a=10, b=20;

printf("Before swap a=%d b=%d",a,b);

a=a-b;

b=a-b;

a=a+b;

printf("\nAfter swap a=%d b=%d",a,b);

}

#include<stdio.h>

int main()

{

int a=10, b=20;

printf("Before swap a=%d b=%d",a,b);

a=a+b;

b=a+b;

a=a-b;

printf("\nAfter swap a=%d b=%d",a,b);

}

#include<stdio.h>

int main()

{

int a=10, b=20;

printf("Before swap a=%d b=%d",a,b);

a=a+b;

b=a-b;

a=a+b;

printf("\nAfter swap a=%d b=%d",a,b);

}

#include<stdio.h>

int main()

{

int a=10, b=20;

printf("Before swap a=%d b=%d",a,b);

a=a+b;

b=a-b;

a=a-b;

printf("\nAfter swap a=%d b=%d",a,b);

}

5.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

The correct output of given code snippet is:-

#include<stdio.h>

int main()

{

int x=5;

printf("%d", x<<1);

return 0;

}

0

5

10

1

Answer explanation

The bitwise left shift operator(<<) shifts all bits towards the left by a certain number of specified bits. The expression x<<1 always returns x*2

6.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

Which code snippet will be executed faster:-

a) #include<stdio.h>

int main()

{

int x=5;

printf("%d", x++);

return 0;

}

b)#include<stdio.h>

int main()

{

int x=5;

printf("%d", x+=1); // same as x=x+1

return 0;

}

Only b

Only a

Both will take same time

It depends on compiler

Answer explanation

x++ being a unary operation, it just needs one variable. Whereas, x = x + 1 is a binary operation that adds overhead to take more time.

7.

MULTIPLE CHOICE QUESTION

1 min • 10 pts

During function call, Default Parameter Passing Mechanism is called as

Call by Reference

Call by Address

Call by Name

Call by Value

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers