Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
28 views6 pages

BOP Lab Viva

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 6

1) Choose the correct program that round off x value (a float value) to an int

value to return the output value 4,


a - float x = 3.6;
int y = (int)(x + 0.5);
printf ("Result = %d\n", y );
b - float x = 3.6;
int y = int(x + 0.5);
printf ("Result = %d\n", y );
c - float x = 3.6;
int y = (int)x + 0.5
printf ("Result = %d\n", y );
d - float x = 3.6;
int y = (int)((int)x + 0.5)
printf ("Result = %d\n", y );

2) What will this program print?


main()
{
int i = 2;
{
int i = 4, j = 5;
printf("%d %d", i, j);
}
printf("%d %d", i, j);
}

a. 4525
b. 2525
c. 4545
d. None of the these
3) What is the output of this statement "printf("%d", (a++))"?

a. The value of (a + 1)
b. The current value of a
c. Error message
d. Garbage

4) Which of the following function can be used to terminate the main() function
from another function safely?

a. return(expr);

b. exit(expr);

c. abort();

d. both exit(expr); and abort();

5) what will be the output of the program?

#include <stdio.h>

int main() {

int i, j;

char input, alphabet = 'A';

printf("Enter an uppercase character you want to print in the last row: ");

scanf("%c", &input);

for (i = 1; i <= (input - 'A' + 1); ++i) {

for (j = 1; j <= i; ++j) {

printf("%c ", alphabet);

++alphabet;
printf("\n");

return 0;

a. A
AB
ABC
ABCD
ABCDE
b. A
BB
CCC
DDDD
EEEEE
c. A
BB
CBC
DBCD
EBCDE
d. A
AA
ABA
ACCA
ADDDA

6) Which of the following will copy the null-terminated string that is in array
src into array dest?

a. dest = src;
b. dest == src;
c. strcpy(dest, src);
d. strcpy(src, dest);
7) what will be the output of the program?

#include<stdio.h>
void main ()
{
Int a[5] = {5, 1, 15, 20, 25};
Int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
Printf(“%d, %d, %d” , I, j, m);
}
a. 3, 2, 15
b. 2, 3, 20
c. 2, 1, 15
d. 1, 2, 5
8) Which is valid expression in c language?

a. int my_num = 100,000;


b. int my_num = 100000;
c. int my num = 1000;
d. int my num == 10000;

9) What will be the output of this program?

int main()

int a=10, b=20;

printf("a=%d b=%d",a,b);
a=a+b;

b=a-b;

a=a-b;

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

return 0;

a. a = 20, b = 20
b. a = 10, b = 20
c. a = 20, b = 10
d. a = 10, b = 10

10) Point out the error in the program?

#include<stdio.h>

#include<stdlib.h>

int main()

unsigned char;

FILE *fp;

fp=fopen("trial", "r");

if(!fp)

printf("Unable to open file");

exit(1);
}

fclose(fp);

return 0;

a. Error: in unsigned char statement

b. Error: unknown file pointer

c. No error

d. None of above

You might also like