0

Computers Test

Description: The beginners who wants to start their career in the field of Information Technology
Number of Questions: 19
Created by:
Tags: IT Information Technology Programming
Attempted 0/19 Correct 0 Score 0

What would be the output of the following program?

main() { char *str,*str1="I Love You"; str=malloc(strlen(str1)); strcpy(str,str1); printf("%s",str); free(str); }

  1. free() fails

  2. I Love You

  3. malloc() fails

  4. strcpy() fails


Correct Option: C

The header file which includes stdarg.h is_____________

  1. assert.h

  2. dos.h

  3. stdio.h

  4. mem.h


Correct Option: C

What are the types of variable f2 and p2 in the following declaration?

#define floatptr float * #define int * intptr

floatptr f1,f2; intptr p1,p2;

  1. float, int pointer

  2. float pointer, int pointer

  3. float, int

  4. float pointer, int


Correct Option: C

_______________ is a direct interface to the DOS call 0x44.

  1. ioctl

  2. ios

  3. dup

  4. tell


Correct Option: B

chmod() function is defined in which header file?

  1. assert.h

  2. dos.h

  3. io.h

  4. mem.h


Correct Option: C

What would be the output of the following?

void main() { int z,x=5,y=-10,a=4,b=2; z=x++ - --y *b/a; printf("%d",z); }

  1. 5

  2. 12

  3. 10

  4. 11


Correct Option: C

In C, what is the difference between a declaration and definition of a variable?

  1. Both can occur multiple times, but a declaration must occur first.

  2. Both can occur multiple times, but a definition must occur first.

  3. A definition occurs once, but declaration may occur many times.

  4. A declaration occurs once, but definition may occur many times.


Correct Option: C

struct node nptr,*sptr; /*pointers for linked list/ for(nptr=sptr;nptr;nptr=nptr->next) { free(nptr); }

Releases memory from a linked list. Which of the following accurately describes how it will work?

  1. It will work correctly since the for loop covers the entire list.

  2. It may fail since each node “nptr” is freed before its next address can be accessed.

  3. This is invalid syntax for freeing memory.

  4. The loop will never end.


Correct Option: B

sizeof is an ________________

  1. int

  2. unsigned int

  3. long int

  4. anyone of the above


Correct Option: A

What would be the output of the following?

char *fun(char *ptr) { ptr+=3; return(ptr); } void main() { char *x,*y; x="Hello"; y=fun(x); printf("%s",y); }

  1. Hello

  2. lo

  3. llo

  4. Error


Correct Option: B

. and -> are __________ operators.

  1. binary

  2. unary

  3. ternary

  4. none of the above


Correct Option: D

What would be the output of the following?

void main() { int a=10,b; b=a++ + ++a; printf("%d %d %d %d",b,a++,a,++a); }

  1. 22 10 11 13

  2. 22 11 11 11

  3. 22 10 11 13

  4. 22 13 13 13


Correct Option: D

The longjmp cannot pass the value

  1. -1

  2. 0

  3. 1

  4. 2


Correct Option: D

What would be the output of the following?

main() { int i=strlen("Blue")+strlen("Purple")/strlen("Red")-strlen("Green"); printf("%d",i); }

  1. 0

  2. 3

  3. 2

  4. 1


Correct Option: D

What would be the output of the following?

main() { int val1=1234; int val2=01234; printf(%d %d,val1,val2); }

  1. 1234 1234

  2. 1234 01234

  3. 1234 668

  4. 1234 688


Correct Option: C

The scope of a global variable which is declared as __________ is within the file.

  1. static

  2. extern

  3. register

  4. function argument


Correct Option: B

What would be the output of the following?

main() { int i,j; for(i=0;;i++) for(j=0;;j++) if(j>100) break; printf("%d%d",i,j); }

  1. System Hangs

  2. 100 100

  3. 0 100

  4. 1 100


Correct Option: A

What would be the output of the following?

main() { int y,x=5; y=++x - ++x; printf("%d%d",x,y); }

  1. 7 1

  2. 7 -1

  3. 7 0

  4. 5 1


Correct Option: B

What would be the output of the following?

void main() { int a=10,b; b=a++ + ++a; printf("%d %d %d %d",b,a++,a,++a); }What would be the output of the following?

void main() { int i=7; printf("%old %old %old %old",i,i++,i--,i++); getch(); }

  1. old old old old

  2. 7ld 8ld 7ld 8ld

  3. 10ld 7ld 10ld 7ld

  4. Error


Correct Option: C
- Hide questions