You are on page 1of 7

C programming

1. The order in which actual arguments are evaluated in a function call a) Is from the left b) is from the right c) Is compiler dependent d) Ordering does not mater, arguments should match its definition 2. Output of following is: main() { extern int i; i=20; printf("%d",sizeof(i)); } a) 2 b) 4 c) Compiler dependent d) Error 3. In a file containing the line I am a boy\r\n , then on reading this line into the array str using fgets(),what would str contain? a) I am a boy\r\n\0 b) I am a boy\r\0 , c) I am a boy\n\0 , d) I am a boy 4. Output of the following loop is main() { for (putchar('C');putchar('a');putchar('r')) putchar('t'); } a) CartCart . b) An error results c) CatrCatr . d) Catratr . 5. If x ia an array, then which of the following cannot be be present in the lhs of an assignment statement? a) x b) x+i c) &x[i] d) All of the above 6. What will be output if you will compile and execute the following c code? struct marks{ int p:3; int c:3; int m:2;

}; void main(){ struct marks s={2,-6,5}; printf("%d %d %d",s.p,s.c,s.m); } a) 2 -6 5 b) 2 -6 1 c) 2 2 1 d) Compiler error 7. What will be output if you will compile and execute the following c code? void main(){ int huge*p=(int huge*)0XC0563331; int huge*q=(int huge*)0xC2551341; *p=200; printf("%d",*q); } a) 0 b) Garbage value c) null d) 200 8. What will be output if you will compile and execute the following c code? void main(){ int i=10; static int x=i; if(x==i) printf("Equal"); else if(x>i) printf("Greater than"); else printf("Less than"); } a) Equal b) Greater than c) Less than d) Compiler error 9. What will be output if you will compile and execute the following c code? void main(){ int i; double a=5.2; char *ptr; ptr=(char *)&a; for(i=0;i<=7;i++) printf("%d ",*ptr++); }

(a) -51 -52 -52 -52 -52 -52 20 64 (b) 51 52 52 52 52 52 20 64 (c) Eight garbage values. (d) Compiler error 10. What will be output if you will compile and execute the following c code? void main(){ printf("%s",__DATE__); } (a) Current system date (b) Current system date with time (c) null (d) Compiler error (e) None of these 11. What will be output if you will compile and execute the following c code? void main(){ int a=-12; a=a>>3; printf("%d",a); } (a) -4 (b) -3 (c) -2 (d) -96 (e) Compiler error 12. int x=sizeof(!5.856); What will value of variable x? What will be output of following c program?

13. #include<stdio.h> #include<conio.h> void main(){ int z; z=(5,3,2); printf("%d",z); }

(A) 5 (B) 3 (C)2 (D)10

14. What does the following fragment of c program print? char c[]="PLACEMENT PREPARATION"; char *p=c; printf("%s",p+p[7]-p[6]); a) LACEMENT PREPARATION b) PLACEMENT c) PREPARATION d) ACEMENT PREPARATION e) Error: invalid operation on pointers 15. What is x in the following program? int main() { typedef char (*(*arrfptr[3])())[10]; arrfptr x; return 0; } A. x is a pointer B. x is an array of three pointer C. x is an array of three function pointers D. Error in x declaration 16. What does the following fragment of c program print? void f (int *p, int * q) { p = q; *p = 2; } int i=0, j=1; int main() { f(&i, & j); printf("%d %d \n", i, j) ;} (A) 2 2 (B) 2 1 (C) 0 1 (D) 0 2 17. What does the following fragment of c program print?

int f(int * a, int n) { if (n <=0)return 0; else if(*a%2== 0) return * a+f(a+ 1,n - 1); else return * a - f(a+ 1, n - 1); } int main ( ) { int a[ ] = {12, 7, 13, 4, 11, 6}; printf("%d", f(a,6)); return 0; } (A) -9 (B) 5 (C) 15 (D) 19 18. Which standard library function will you use to find the last occurance of a character in a string in C? A. strnchar() B. strchar() C. strrchar() D. strrchr() 19. In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h A. During editing B. During linking C.During execution D.During preprocessing 20. choose the correct statements. a. address is the numeric value associated with a memory location b. two variables can have the same address c. address is bound to a variable by the compiler d. value of a variable can be an address

OS
1. If a disk has a seek time of 20ms, rotates 20 rps, has 100 words per block, and each track has capacity of 300 words. Then total time required to access one block is a. 25 b. 30

c. 40 d. 60 2. Consider three CPU intensive processes, which requires 10,20 and 30 time units and arrive at times 0,2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end. a. 1 b. 2 c. 3 d. 4 3. The process executes the following code for (i=0;i<n;i++) for k(); a. n b. 2n-1 c. 2n d. 2n+1-1 4. A system has n resources R0 .Rn-1, and k processes P0 Pk-1. The implementation of the resource request logic of each process Pi, is as follows: if (i%2==0){ if(i<n) request Ri; if (i+2<n) request Ri+2; } else{ if(i<n) request Rn-i; if (i+2<n) request Rn-I - 2; } In which of the following situation is a deadlock possible? a. n=40,k=26 b. n=21,k=12 c. n=20,k=10 d. n=41,k=19

CN
1. which of the following uses UDP as the transport protocol? a. HTTP b. Telnet c. DNS d. SMTP 2. What is the full form of: SMTP a. Sending mail transfer protocol b. Simple mail transfer protocol c. Synchronised mail transfer protocol

3.

4.

5.

6.

7.

8.

9.

10.

d. Serialized mail transfer protocol Which of the following is not relevant to networking? a. Low end stand alone hubs b. Stackables hubs c. Mesh network d. Bus hubs Which one of the following is not a class of LAN? a. Broad Band b. CSMAICD c. Token bus d. Token ring Which of the following is a wrong example of network layer? a. IP ARPA NET b. X.25 packet land protocols(PLP-ISO) c. Source routing and Domain Naming Usenet d. X.25 level 2-ISO End-to end connectivity is provided from host-to-host in the a. Network layer b. Transport layer c. Session layer d. Physical layer In the context of OSI or TCP/IP computer network models, which of the following is false? a. Besides span of geographical are, the other major difference between LAN and WAN is that later uses switching element b. A repeater is used just to forward bits from one network to another one c. IP layer is connected oriented layer in TCP/IP d. A gateway is used to connect incompatible networks Router function in which layer(s)? a. Physical and data link layer b. Network layer c. Physical, data link and network layer d. Network and transport layer Frames are generated by a. DLL in OSI mode, SATNET in TCP/IP,TC in ATM b. DLL in OSI mode, TC in TCP/IP,SATNET in ATM c. DLL in OSI mode, ARPANET in TCP/IP,TC in PMD d. DLL in OSI mode, TC in TCP/IP,SATNET in ATM Which computer was the first node of the internet? a. IMPL b. UCLA c. IFNC d. Sorry, I have no idea

You might also like