Global Edge
1. main(){ int i; i=(2,3); printf("%d",i); }
a)2 b)3 c)Compiler error d)Syntax error.
ans : 3
2. main(){ char str[]="GESL"; printf("%d %d",sizeof(str),strlen(str)); }
a)5,5 b)4,4 c)5,4 d)4,5 ans: 5, 4
3. main(){ for(i=0;i++;i<100) printf("hello world\n"); }
a)100 times b)0 times c)Infinite loop d)None of the above.
ans: 0 times.
4. main(){ for(i=1;i++;i<100) printf("hello world\n"); }
a)100 times b)0 times c)Infinite loop d)None of the above.
ans: infinite loop
5. main(){ char c; scanf("%s",c); }
a)Compiler dependent b)unpredictable c)Compiler error d) scans the i/p.
ans: Compiler dependent.
6. main(){ int k=5; for(++k<5 && k++/5 ++k<8); printf("%d\n",k); }
a)5 b)6 c)7 d)8
ans: 7
7. main(){ int *ptr1,*ptr2; ptr1=(int *)malloc(sizeof(int)); ptr2=func(20,10,ptr1); printf("%d %d\n",*ptr1,*ptr2); }
int *func(int a, int b, int *c) { int x=a+b; *c=a-b; return(&x);}
a)Bug in the code. b)No Bugs prints correctly c)Error d) None of the above.
Ans: Bug in the code.
8). int main() { int i = 10, j ; if ( ( j = ~i ) < i ) printf ( "True" ) ; else printf ( "False" ) ; }
a) True b) False c) Compiler Dependent d) None of the above.
ans : True 9. How many bytes are required to create a 3*3 matrix using double pointer ans: 12 10. take int=4,float=8,char=1 main() { FILE *fp; printf("%d\n",sizeof(fp) ); }
a)2 b)4 c)Compiler dependent d)Error
Ans:4
11. main() { int a=10,20; a^=b^=a^=b; printf("%d\n %d\n",a,b); a)a=20,b=10 b)a=10,b=20 c)Syntax error d)Unpredictable
Ans : a=20 b=10 12. main() { int i=10;
switch(i) { case 10: printf("Hello "); { case 1 : printf("World "); } case 5: printf("Hello World "); } }
a) Hello b) Hello c) Hello World Hello World d) Syntax Error. Ans : Hello World Hello World13. main() { char str1[]="Hello"; char str2[]="Hello"; if ( str1==str2 ) printf("True\n"); else printf("False\n"); } Ans: False. a)True b)False c)Error d) Unpredictable.
15. main() { # include int i = 10 ; printf("%d\n", i/2 ); } a)10 b)5 c)error d) warning. ans : 5 16. #include # pragma pack(2)
struct SIZE { int i; char ch ; double db ; } ; main () { printf ( "%d\n",sizeof(struct SIZE) ); } a)12 b)14 c)16 d)8
/* C question and answers All questions are tested in Turbo C compiler and have not been tested in gcc or (linux platform) */----------------------------------------------------1)#includemain(){ scanf("%d"); printf();}which of the following is correct?a)compilation errorb)Run time errorc)No outputd)depends on the compiler
ans : a---------------------------------------------------------2)#include#define islower(c) ('a'<=(c) && (c)<='z')#define toupper(c) (islower(c)?(c)-('a'-'A'):(c))
main(){ char *p="i am fine"; while(*p) printf("%c",toupper(*p++));}a)bcdb)AFEc)aFed)BCd
ans : b ( macro substitution 3 times)----------------------------------------------------------3)#includemain(){ 200; printf("tricky problem");}a)warning messageb)compilation errorc)run time errord)none of these
ans : a------------------------------------------------------------4)which is the null statement?a) ;b) {} c) '\0';d)all of these
ans : a------------------------------------------------------------5)what is the correct prototype of printf function ?a)printf(char *p,...);b)printf(const *char *p,...);c)printf(const char *p,...);d)printf(const *char p,...);
ans : c-----------------------------------------------------------
/* questions on computer concepts */
1)which of the following is not a system file?a).sysb).comc).inid)none
ans : d---------------------------------------------------------------2)A magnetic tape is equivalent to which of the following structure?a)Graphsb)treesc)Listsd)Dictionaries
ans : c------------------------------------------------------------3)For a linked list implementation which searching technique is notapplicable?a)linear searchb)nonec)quick sortd)binary search
ans : d----------------------------------------------------------------4)Encryption and decryption is done in which layer?a)DLLb)Network layerc)transport layerd)presentation layer
ans : d------------------------------------------------------------5)which of the following is not performed by the OS?a)cpu shcedulingb)memory managementc)Transactiond)none
ans : c
1>
main(){ int arr[]={ 1,2,3,4 }; int *ptr ;;;; ptr++ = arr; printf("%d,%d",ptr[2],arr[2]); return 0;}what is the output :
a> compile time error :multiple termination statements for pointerb> lvalue required for ptrc> prints 3 3d> printd 4 3
ans b: lvalue required for ptr;
2>
main(){ char s[10]; scanf ("%s",s); printf(s);
}
what is the output if input is abcd :
a> prints abcd b> compiler error c> prints abcd and 6 junk characters d> printd s
ans a: prints abcd.
3>
main(){ char c = 255; printf ("%d",c); return 0;}
what is the output
a> illegal character assignmentb> prints -1c> prints 2d> prints 255
ans b: prints -1.
4>main(){ int i; for (i=7;i<=0;i--) printf ("hello\n");
}
what is the output
a> prints hello 7 timesb> prints hello 8 timesc> prints hello onced> prints nothing
ans b: prints nothing.
5>
main(){ printf( printf ("world") );
}
a> prints worldb> prints printf ("world")c> prints nothingd> compiler error
ans d: compiler error.
computer concepts
1> A c source code file can be
a> compiled onlyb> interpreted onlyc> both compiled and interpretedd> nothing
ans c : both compiled and interpreted
2> c programming approach is
a> Top downb> bottom upc> both topdown and bottom upd> none of the above
ans a:top down approach
3> The access time is less for
a> hard diskb> cachec> registersd> main memory
ans c:registers
4>resolving of external variables in a program is done at
a>complie timeb>run timec>link time4>load time
ans c: link time.
5> interrupts inform process about
a> events external to process asynchronouslyb> events external to process synchronouslyc> both a and bd> events internal to a process
ans a: events external to process asynchronously
1. What is the output of the following code ?
int main( ) { for( ; ;); printf("Hello\n"); return 0; }
a. give compilation errorb. prints Hello infinite timesc. Runs in an infinite loop without printing anything.d. prints Hello once.
Ans: c
2. Output of the code? FUNC (int *p) { p = (int *)malloc(100); printf("p:%x",p); }
int main( ) { int *ptr; FUNC(ptr); printf("Ptr:%x",ptr); return 0; }
a. Both printf statements prints same values. b. Both print different values. c. Gives compile time error. d. Gives run time error.
Ans: b
3. Output of the code? int main() { char a[] = "world"; printf("%d %d\n",strlen(a),sizeof(a)); return 0; } a. 5,5 b. 6,5 c. 5,6 d. 6,6
Ans: c
4. What is the output generated? main() { char *s = "Hello"; printf("%s",1(s)); }
a. Hellob. elloc. ed. none of these.
Ans: b
5. Interpret the given declaration char ( * ( f ( ) ) [ ] )( )
a. f is a pointer to function returning char b. f is a pointer to an array of function returning a charc. Invalid declarationd. f is a function returning pointer to array[] of pointer to function returning char.
Ans : d
1. A binary tree of height h, h > 0 has
a. at least h and atmost 2*h-1 elements in it. b. at least 2^h and atmost (2^h)+1 elementz in it. c. at least 2^h -1 and atmost h^2 elements in it. d. at least h and atmost (2^h) - 1 elements in it.
Ans: d
2. Thrashing is a. flooding of pages in the memory. b. increase in removal of pages from memory. c. increase in page faults leading to decrease in CPU utilization. d. removal of unused pages from memory making space for new ones.
Ans: c
3. Recursive Descent parser is a type of a. Bottom up parser. b. Top Down parser. c. None of these. d. Bottom down parser.
Ans: b
4. alloca() allocates memory from a. Heap. b. Reserved memory. c. Data segment. d. Stack.
Ans: d
5. What is the octal equivalent of decimal (5468). a. 12360. b. 12560. c. None of these. d. 12650.
Ans : c
C:
1.what is the o/p ?
void main(){ char *mess[]={"Have","a","nice","day","Bye"); printf("%d \t %d",sizeof(mess),sizeof(mess[1]));} a. 16 4b. 5 4c. 20 4d. Error answer: c
2.what is the o/p of the following programe?void main(){ int i,count=0; char *p1="abcdefghij"; char *p2="alcmenfoip";
for(i=0;i<=strlen(p1);i++) { if(*p1++ == *p2++) count+=5; else count-=3; } printf("count=%d\n",count);} a. 15b. 6c. 12d. compiler error answer: b ( note : strlen(p1) == i when i=6)
3.what does main return on successful execution?a. 1b. 0c. -1d.Nonzero answer:b
4.main(int argc,char *argv[]){ printf((argc > 1 ? "%c" : "%c",*++argv);}If the i/p string is "GESL Bangalore".a. Gb. Ec. Bd. GESL answer: c
5. How do u declare a pointer to an array of pointers to int?a. int *a[5];b. int **a[5];c. int *(*a)[5];d. u con not declare answer: c
Questions on OS:
1.UDP is aa. Reliable protocolb. Unreliable protocolc. Connectionless protocold. Both b & c Answer: d
2.Real Time OS usesa. RISC processorb. CISC processorc. SISC processord. Any of the above Answer: a
3.Race condition could be overcome usinga. A global variableb. A local variablec. Mutexd. All of the above
4.Repeaters are ina. Data link layerb. Physical layerc. Network layerd. Transport layer Answer: b
5.Telecom Networking usesa. Packet switchingb. Circuit switchingc. Message switchingd. Non of the above
Ans : b ( normally )( packet switching in ISDN )
1)what is big-endian.a) MSB at lower address LSB at higher addressb) LSB at lower address MSB at higher addressc) memory mgmt techniqued) none of the aboveans:a2)what is Little-endian.a) MSB at lower address LSB at higher addressb) LSB at lower address MSB at higher addressc) memory mgmt techniqued) none of the aboveans:b3)8086 hasa)16 bit data bus ,16 bit address busb)16 bit data bus,32 bit address busc)8 bit data bus,16 bit address busd)8 bit data bus,8 bit address busans:a4) what is the scheduling algorithm used in general operating systems.a) FCFS algorithmb) Highest Priority First algorithmc) Round-Robin algorithmd) None of the aboveans:c5)Router is present ata)Physical layerb)Data Link Layerc)Network Layerd)None of aboveans:c6)Condition for deadlock occurancea) Mutual Exclusionb) no premptionc) hold and waitd) circular waite) all of the aboveans:d7)PCI stands fora)Programmable computer Interfaceb)Peripheral Computer Interfacec)programmable Control Interfaced)Peripheral Component Interfaceans:d8)Toggle state in J-K flip-flop isa)0 1b)1 0c)1 1d)0 0ans :c9)Interrupt is serviceda)Immediatly when it occursb)After the completion of current instruction.c)Ignoredd)None of the above.ans:b
1) main(){ int a; char *p; a = sizeof(int) * p; printf("%d\n",a); }a)compile errorb)run time errorc)4d)compiler dependentans:a2)#define SIZE sizeof(int) main(){ int i=-1; if( i < SIZE ) printf("True\n"); else printf("False\n"); }a) Trueb) Falsec) can't predictd) None of theseans:b (?)
3) int (*fun())[]a) function returning a pointer to an arrayb) function returning an array of pointersc) pointer to a funtion which takes array as asrumentd) Compiler errorans: a4) main(){ int a=8,d; int *p; p=&a; d=a/*p; print("%d\n",d); }a) 1b) 0c) compiler errord) run time errorans: c5)main(){ char *a="Hello"; *a++ = 'h'; printf("%s\n",a); }a) hellob) elloc) runtime errord) compiler errorans:b6) main(){ char p[]="Hello"; p[0]='h'; printf("%s\n", p); }a) hellob) Helloc) compiler errord) run time errorans:a7)#define mysizeof(a) (&a+1) - &a main( float d; printf("%d\n", mysizeof(d) ); }note: assume sizeof float is 8 bytesa) 8b) 4c) 1d) compiler errorans:c8) main() { int *p=10; printf("%d\n",*p); }a) 10b) run time errorc) compiler errord) 5ans:b (?)
9)main(){ int i=-1; i<<=2; printf("%d\n",i); }a) -1b) -2c) -4d) 0ans:c10) main(){ int i= 0xffffffff; printf("%d\n",i); }note: size of int is 4 bytesa) -1b) 65635c) 100d) errorans:a
1. Where is the MBR stored? 1. maintained by OS 2. MBR is in Boot. 3 MBR is in First sector of HDD 4. None of the above. 2. Where is the partition table stored? 1. BIOS 2. CMOS Setup 3. MBR 4. stored per partition.3. Where is the boot record stored? 1. BIOS 2. CMOS Setup 3. MBR 4. stored per partition.4. How many primary partitions can be created? 1. 1 2. 2 3. 3 4. 4 ans : 4.
5. What is the difference between primary & extended partion? 1. Both are same 2. Primary and extended are in logical partion 3. primary cannot be subdivided but extended can be. 4. extended cannot be subdivided but primary can be. ans 3.
6. Can we create 2 primary dos partions? a)Yes b)No c)Depends on the hard Disk. d)None of the above. Ans: Yes 7. Can we create 2 extended partitions ?
a)Yes b)No c)Depends on the hard Disk. d)None of the above. Ans: No.
8. How many partitions can be created on a given harddisk? a) Depends on the size of Disk. b) 24 c)4 d)26
9. Can we hide a partition? a) Yes b) No c) Depends on the Hard Disk d) None. ans: Yes.
10. Sliding window protocol lies in which layer? 1. Transport Layer 2. network Layer 3. Datalink layer 4. Application Layer
Ans : 3. DAtalink layer
11. Which is the highest priority interrupt . 1. rst5.5 2. rst6.5 3. TRAP 4. HLD 12. 8085 is 1. 16-bit 2. 8-bit 3. 32-bit 4. 20-bit microprocessor.
Ans : 2. 8 bit
13. protected mode is present in which processor 1. 8085 2. 8086 3. 80386 4.8087 14. The no. of address lines required to address 4k of memory a)11 b)12 c) 14 d) 16 Ans: b 15) Where is CMOS setup stored a) Hard Disk b) BIOS c)CMOS Ram d) MBR.
Ans : CMOS Ram
C questions
1> int A=1,B=2; if(A==B < printf("Hello ")) printf("world\n"); else printf("Bangalore\n");
What is the o/p?
a> world b> Hello bangalore c> bangalore d> Hello world.
ans > d> Hello world.
2>
main() { int i; for(i=0; i< 10; i++) { int j=10; j++; printf("j= %d\n", j); } }
what is o/p ?
a> 10 to 19 b> error j undeclared c> 10 times 11 d> 10 - 18
ans> c> 10 times 11.
3> union test{ int a; union test *p; }; main(){ union test q; printf(" a= %d\n ", q.a); } what is o/p?
a> 0 b> syntax error c> garbage value d>run time error
ans > c
4>
register int a,b; main(){ for(a=0 ; a<5 ; a++) b++; }
a> 5 b> 4 c> 0 d> error
ans > d
5> # define dprint(expr) printf(" expr= %d \n ", expr)
main(){
int i=10,j=2;
dprint(i / j) ; }
a> 5 b > expr= 5 c> i / j= 5 d> error.
ans > b.
Operating system concepts
1> Virtual memory is
a> Infinite, user is not constrained while writing program. b> Finite it is limited by main memory + swap memory. c> Infinite ,Yes As the process needs memory it is allocated by demand paging. d> Finite ,It is limited by machines addressing capacity.
ans> d
2> Find the correct sentence
a> UNIX is monolithic MS-DOS is Microkernel b> UNIX & MS-DOS are both monolithic. c> UNIX & MS-DOS are both Microkernel. d> All are wrong. ans> b
3> In which OSI layer packet sequencing is checked
a> Physical layer b> Data link layer c> Network layer d> Transport layer
ans> d
4> In General purpose OS user cannot change which state of process.
a> premption b> sleep c> creation d> ready
ans> a
5> Which addressing scheme is not common for 8085 & 8086
a> Register addressing b> Indexed addressing c> Register Indirect addressing d> Direct addressing. Ans: b
C :
What is the output of the following :1. main() { int *p ; p=(int *)malloc(-10); }
a) allocates 0 bytesb) allocates memory, if available c) compilation errord) Runtime error
Ans) b
2. main() { for( printf("a") ; printf("b") ; printf("c") ) ; }
a) abcb) abc abc abc .....(infinite times)c) a bc bc bc ....(infinite times)d) Error
Ans) c
3. main() { int i= 10 * fun() ; printf("%d",i); }
fun() { return 10 ; }
a) 0 b) 10c) 100d) Error
Ans) c
4. int i= 10 * fun() ; main() { printf("%d",i) ; }
fun() { return 10 ; }
a) 0b) 10c) 100d) Error
Ans) d
5. Assume size of int to be 2 bytes :
main() { int i = 100 ; printf("%d ", sizeof(i++)); printf("%d ",i) ; }
a) 2 100b) 2 101c) 100 101d) 101 100
Ans) a
Computer Fundamentals :
1. Which one of the following always resides in the memory ?
a) Linkerb) Loaderc) Compilerd) All of the Above
Ans) b
2. Which of these is not a layer in OSI model ?
a) Application layerb) Network Layerc) Internet Layerd) Data Link Layer
Ans) c
3. Which one of the following data structures is best suited for searching ?
a) Arraysb) Singly Linked Listc) Doubly Linked Listd) Hash Table
Ans) d
4. Which of the following data structures is best suited for Deletion ?
a) Arrays b) Singly Linked Listc) Doubly Linked Listd) Hash Table
Ans) c
5.Which one of these is not a scheduling technique in Operating System?
a) Last-Come-First-Serve Schedulingb) First-Come-First-Serve Schedulingc) Preemptive Schedulingd) Round Robin Scheduling
Ans) a
6. Demand Paging is
a) All the pages of a process is loaded at the startb) When a single page is demanded then all other pages are also loadedc) When a page is required then only it is loaded d) None of the Above
Ans) c
7. Page Fault is
a) A page is referenced that is not in the memory .b) A page is referenced that is not in the Disk.c) A page being added to the process.d) None of the above
Ans) a
8. If the number of internal nodes in a binary tree is n , then what is the number of external nodes ?
a) n -1b) nc) n + 1d) 2n
Ans) c
9. "Banker's Algorithm" is used for :
a) Deadlock Detectionb) Deadlock Avoidancec) Deadlock Preventiond) All of the above
Ans) b
10. Which of the following is used fro designing a lexical analyser of a compiler ?
a) Finite Automatab) Push Down Automatac) Turing Machine d) None of the above
Ans) a
11. Which layer in the OSI model is responsible for End to End connectivity ?
a) Data Link Layerb) Network Layerc) Transport Layerd) Session Layer
Ans) c
(1) : TRUE */1. What is the Output of the Program ? main() { int a = 1; #define p a printf("%d %d ",a++,p++) ; } a) 1, 0 b) 2, 0 c) 1 2 d) none of the above Ans (d)2. What is the Output of the Program ? #include main() { #include int a = 90 ; printf("%d",a) ; } a) 90 b) compilation error c) linker error d) runtime error Ans (a)3. What is the Output of the Program ? main() { main() ; } a) compilation error b) runtime error c) executes until the stack overflows(1) d) none of the above Ans (c)4. What is the Output of the Program ? #define max "hello" main() { printf(max) ; } a. compilation error b. Preprocessing error c. runtime error d. hello Ans (d)5. What is the Output of the Program ? #define max main() main() { max ; printf("hello wolrd\n ") ; } a. compilation error b. Preprocessing error c. runtime error d .executes until the stack overflows6. What is the Output of the Program ? typedef int *p ; main() { int a = 90 ; p p1 ; p1 = &a ; printf("%d",*p1) ; } a. 90 b. compilation error c. runtime error d. none of the above Ans (a)7. What is the Output of the Program ? main() { int i = 1 ; printf(i ?"one" : "zero") ; } a. one b. zero c.error d. both and b Ans (a)8. What is the Output of the Program ? main() { int i = 1 ; printf("%d",i ? 1 : 0) ; } a. 1 b. 0 c. error d. none of the above 9. What is the Output of the Program ? main() { int a = 90 , b = 100 ; a++ ; a = (a ^ b) ^ (a = b ); b = a^b^a ; --a ; printf("%d %d",a++,b++) ; } a. 90 100 b. 100 90 c. 101 91 d. 91 101 Ans (a)10. What is the Output of the Program ? main() { int a = 10 , b = 100 ; swap(&a , &b) ; printf("%d %d",a,b) ; } swap(int *a , int *b) { *a = *a + *b ; *b = *a - *b ; *a = *a - *b ; swap1(&a , &b) ; } swap1(int **a , int **b) { **a = **a + **b ; **b = **a - **b ; **a = **a - **b ; } a. 100 10 b. 10 100 (1) c lvalue is required in fun main d. error !! Ans (b)
11. What is the Output of the Program ? main() { void *ptr ; int a = 10 ; ptr = &a ; printf("%d",*ptr) ; } 1. error 2. 10 3. 20 4. none Ans (1)
12. What is the Output of the Program ? main() { void *ptr ; int a = 90 ; char *ptr1 = "hello" ; ptr = a ; ptr = ptr1 ; } a. executes w/o any error b. compilation error c. runtime error d.none Ans (a)
13. What is the Output of the Program ? main() { char *p = "helloo" ; char *p1 = "strcat" ; while((*(p++) = *(p1++)) != '\0') { ; } } a. error b. address is copied c. contents are copied d . none Ans (c)14. What is the Output of the Program ? int g = 10 ; main() { int a = 10 ; printf("%d",a) ; } int g ; a. 10 b. 11 c. error d. none Ans (a)15. What is the Output of the Program ? main() { int a = 1 ; int b = 0 ; a = a++ + --b * a++ ; printf("%d",a) ; } a. error b. none c. 1 d .2 Ans (d)16. What is the Output of the Program ? struct s { int si; union u { float uf; char uc; }; }; main() { printf("%d",sizeof(struct s)); } a. 8 b. 3 c. 6 @ d. 7
17. What is the Output of the Program ? struct st { int a; char b; } main() { } a. struct st is return type of main@ b. main is a variable of struct st. c. Compilation error d. Run time error Ans (A)-----------------------------------------------------18. What is the Output of the Program ? typedef struct info { int i; char b; } node; main() { struct info node1; node1.i=55; printf("%d",node1.i); } a. 55 b. Not possible to use struct info c.Compilation error d. Garbage value. Ans (A)19. What is the Output of the Program ? struct a { int i; int display() { printf("hello world\n"); } }; main() { strcut a vara; vara.display(); } a. hello b. hello world c. Compile time error d. garbage 20. What is the Output of the Program ? struct a { int (*ptr)(); }; int display() { printf("Global Edge\n"); } main() { struct a structa; structa.ptr=display; structa.ptr(); } A. Global Edge B. Address of display function C. address of structa D.Error Ans (A)21. What is the Output of the Program ? typedef int *ABC; typedef ABC XYZ[10]; int main() { XYZ var; } 1. var is an array of integer pointers. 2. var is a pointer to an integer array. Options: a) only 1 is correct. b) only 2 is correct. c) both 1 and 2 are correct. d) typedef statements are in wrong order. Answer : b
(1) : TRUE */1. What is the Output of the Program ? main() { int a = 1; #define p a printf("%d %d ",a++,p++) ; } a) 1, 0 b) 2, 0 c) 1 2 d) none of the above Ans (d)2. What is the Output of the Program ? #include main() { #include int a = 90 ; printf("%d",a) ; } a) 90 b) compilation error c) linker error d) runtime error Ans (a)3. What is the Output of the Program ? main() { main() ; } a) compilation error b) runtime error c) executes until the stack overflows(1) d) none of the above Ans (c)4. What is the Output of the Program ? #define max "hello" main() { printf(max) ; } a. compilation error b. Preprocessing error c. runtime error d. hello Ans (d)5. What is the Output of the Program ? #define max main() main() { max ; printf("hello wolrd\n ") ; } a. compilation error b. Preprocessing error c. runtime error d .executes until the stack overflows6. What is the Output of the Program ? typedef int *p ; main() { int a = 90 ; p p1 ; p1 = &a ; printf("%d",*p1) ; } a. 90 b. compilation error c. runtime error d. none of the above Ans (a)7. What is the Output of the Program ? main() { int i = 1 ; printf(i ?"one" : "zero") ; } a. one b. zero c.error d. both and b Ans (a)8. What is the Output of the Program ? main() { int i = 1 ; printf("%d",i ? 1 : 0) ; } a. 1 b. 0 c. error d. none of the above 9. What is the Output of the Program ? main() { int a = 90 , b = 100 ; a++ ; a = (a ^ b) ^ (a = b ); b = a^b^a ; --a ; printf("%d %d",a++,b++) ; } a. 90 100 b. 100 90 c. 101 91 d. 91 101 Ans (a)10. What is the Output of the Program ? main() { int a = 10 , b = 100 ; swap(&a , &b) ; printf("%d %d",a,b) ; } swap(int *a , int *b) { *a = *a + *b ; *b = *a - *b ; *a = *a - *b ; swap1(&a , &b) ; } swap1(int **a , int **b) { **a = **a + **b ; **b = **a - **b ; **a = **a - **b ; } a. 100 10 b. 10 100 (1) c lvalue is required in fun main d. error !! Ans (b)
11. What is the Output of the Program ? main() { void *ptr ; int a = 10 ; ptr = &a ; printf("%d",*ptr) ; } 1. error 2. 10 3. 20 4. none Ans (1)
12. What is the Output of the Program ? main() { void *ptr ; int a = 90 ; char *ptr1 = "hello" ; ptr = a ; ptr = ptr1 ; } a. executes w/o any error b. compilation error c. runtime error d.none Ans (a)
13. What is the Output of the Program ? main() { char *p = "helloo" ; char *p1 = "strcat" ; while((*(p++) = *(p1++)) != '\0') { ; } } a. error b. address is copied c. contents are copied d . none Ans (c)14. What is the Output of the Program ? int g = 10 ; main() { int a = 10 ; printf("%d",a) ; } int g ; a. 10 b. 11 c. error d. none Ans (a)15. What is the Output of the Program ? main() { int a = 1 ; int b = 0 ; a = a++ + --b * a++ ; printf("%d",a) ; } a. error b. none c. 1 d .2 Ans (d)16. What is the Output of the Program ? struct s { int si; union u { float uf; char uc; }; }; main() { printf("%d",sizeof(struct s)); } a. 8 b. 3 c. 6 @ d. 7
17. What is the Output of the Program ? struct st { int a; char b; } main() { } a. struct st is return type of main@ b. main is a variable of struct st. c. Compilation error d. Run time error Ans (A)-----------------------------------------------------18. What is the Output of the Program ? typedef struct info { int i; char b; } node; main() { struct info node1; node1.i=55; printf("%d",node1.i); } a. 55 b. Not possible to use struct info c.Compilation error d. Garbage value. Ans (A)19. What is the Output of the Program ? struct a { int i; int display() { printf("hello world\n"); } }; main() { strcut a vara; vara.display(); } a. hello b. hello world c. Compile time error d. garbage 20. What is the Output of the Program ? struct a { int (*ptr)(); }; int display() { printf("Global Edge\n"); } main() { struct a structa; structa.ptr=display; structa.ptr(); } A. Global Edge B. Address of display function C. address of structa D.Error Ans (A)21. What is the Output of the Program ? typedef int *ABC; typedef ABC XYZ[10]; int main() { XYZ var; } 1. var is an array of integer pointers. 2. var is a pointer to an integer array. Options: a) only 1 is correct. b) only 2 is correct. c) both 1 and 2 are correct. d) typedef statements are in wrong order. Answer : b
a)2 b)3 c)Compiler error d)Syntax error.
ans : 3
2. main(){ char str[]="GESL"; printf("%d %d",sizeof(str),strlen(str)); }
a)5,5 b)4,4 c)5,4 d)4,5 ans: 5, 4
3. main(){ for(i=0;i++;i<100) printf("hello world\n"); }
a)100 times b)0 times c)Infinite loop d)None of the above.
ans: 0 times.
4. main(){ for(i=1;i++;i<100) printf("hello world\n"); }
a)100 times b)0 times c)Infinite loop d)None of the above.
ans: infinite loop
5. main(){ char c; scanf("%s",c); }
a)Compiler dependent b)unpredictable c)Compiler error d) scans the i/p.
ans: Compiler dependent.
6. main(){ int k=5; for(++k<5 && k++/5 ++k<8); printf("%d\n",k); }
a)5 b)6 c)7 d)8
ans: 7
7. main(){ int *ptr1,*ptr2; ptr1=(int *)malloc(sizeof(int)); ptr2=func(20,10,ptr1); printf("%d %d\n",*ptr1,*ptr2); }
int *func(int a, int b, int *c) { int x=a+b; *c=a-b; return(&x);}
a)Bug in the code. b)No Bugs prints correctly c)Error d) None of the above.
Ans: Bug in the code.
8). int main() { int i = 10, j ; if ( ( j = ~i ) < i ) printf ( "True" ) ; else printf ( "False" ) ; }
a) True b) False c) Compiler Dependent d) None of the above.
ans : True 9. How many bytes are required to create a 3*3 matrix using double pointer ans: 12 10. take int=4,float=8,char=1 main() { FILE *fp; printf("%d\n",sizeof(fp) ); }
a)2 b)4 c)Compiler dependent d)Error
Ans:4
11. main() { int a=10,20; a^=b^=a^=b; printf("%d\n %d\n",a,b); a)a=20,b=10 b)a=10,b=20 c)Syntax error d)Unpredictable
Ans : a=20 b=10 12. main() { int i=10;
switch(i) { case 10: printf("Hello "); { case 1 : printf("World "); } case 5: printf("Hello World "); } }
a) Hello b) Hello c) Hello World Hello World d) Syntax Error. Ans : Hello World Hello World13. main() { char str1[]="Hello"; char str2[]="Hello"; if ( str1==str2 ) printf("True\n"); else printf("False\n"); } Ans: False. a)True b)False c)Error d) Unpredictable.
15. main() { # include
struct SIZE { int i; char ch ; double db ; } ; main () { printf ( "%d\n",sizeof(struct SIZE) ); } a)12 b)14 c)16 d)8
/* C question and answers All questions are tested in Turbo C compiler and have not been tested in gcc or (linux platform) */----------------------------------------------------1)#include
ans : a---------------------------------------------------------2)#include
main(){ char *p="i am fine"; while(*p) printf("%c",toupper(*p++));}a)bcdb)AFEc)aFed)BCd
ans : b ( macro substitution 3 times)----------------------------------------------------------3)#include
ans : a------------------------------------------------------------4)which is the null statement?a) ;b) {} c) '\0';d)all of these
ans : a------------------------------------------------------------5)what is the correct prototype of printf function ?a)printf(char *p,...);b)printf(const *char *p,...);c)printf(const char *p,...);d)printf(const *char p,...);
ans : c-----------------------------------------------------------
/* questions on computer concepts */
1)which of the following is not a system file?a).sysb).comc).inid)none
ans : d---------------------------------------------------------------2)A magnetic tape is equivalent to which of the following structure?a)Graphsb)treesc)Listsd)Dictionaries
ans : c------------------------------------------------------------3)For a linked list implementation which searching technique is notapplicable?a)linear searchb)nonec)quick sortd)binary search
ans : d----------------------------------------------------------------4)Encryption and decryption is done in which layer?a)DLLb)Network layerc)transport layerd)presentation layer
ans : d------------------------------------------------------------5)which of the following is not performed by the OS?a)cpu shcedulingb)memory managementc)Transactiond)none
ans : c
1>
main(){ int arr[]={ 1,2,3,4 }; int *ptr ;;;; ptr++ = arr; printf("%d,%d",ptr[2],arr[2]); return 0;}what is the output :
a> compile time error :multiple termination statements for pointerb> lvalue required for ptrc> prints 3 3d> printd 4 3
ans b: lvalue required for ptr;
2>
main(){ char s[10]; scanf ("%s",s); printf(s);
}
what is the output if input is abcd :
a> prints abcd b> compiler error c> prints abcd and 6 junk characters d> printd s
ans a: prints abcd.
3>
main(){ char c = 255; printf ("%d",c); return 0;}
what is the output
a> illegal character assignmentb> prints -1c> prints 2d> prints 255
ans b: prints -1.
4>main(){ int i; for (i=7;i<=0;i--) printf ("hello\n");
}
what is the output
a> prints hello 7 timesb> prints hello 8 timesc> prints hello onced> prints nothing
ans b: prints nothing.
5>
main(){ printf( printf ("world") );
}
a> prints worldb> prints printf ("world")c> prints nothingd> compiler error
ans d: compiler error.
computer concepts
1> A c source code file can be
a> compiled onlyb> interpreted onlyc> both compiled and interpretedd> nothing
ans c : both compiled and interpreted
2> c programming approach is
a> Top downb> bottom upc> both topdown and bottom upd> none of the above
ans a:top down approach
3> The access time is less for
a> hard diskb> cachec> registersd> main memory
ans c:registers
4>resolving of external variables in a program is done at
a>complie timeb>run timec>link time4>load time
ans c: link time.
5> interrupts inform process about
a> events external to process asynchronouslyb> events external to process synchronouslyc> both a and bd> events internal to a process
ans a: events external to process asynchronously
1. What is the output of the following code ?
int main( ) { for( ; ;); printf("Hello\n"); return 0; }
a. give compilation errorb. prints Hello infinite timesc. Runs in an infinite loop without printing anything.d. prints Hello once.
Ans: c
2. Output of the code? FUNC (int *p) { p = (int *)malloc(100); printf("p:%x",p); }
int main( ) { int *ptr; FUNC(ptr); printf("Ptr:%x",ptr); return 0; }
a. Both printf statements prints same values. b. Both print different values. c. Gives compile time error. d. Gives run time error.
Ans: b
3. Output of the code? int main() { char a[] = "world"; printf("%d %d\n",strlen(a),sizeof(a)); return 0; } a. 5,5 b. 6,5 c. 5,6 d. 6,6
Ans: c
4. What is the output generated? main() { char *s = "Hello"; printf("%s",1(s)); }
a. Hellob. elloc. ed. none of these.
Ans: b
5. Interpret the given declaration char ( * ( f ( ) ) [ ] )( )
a. f is a pointer to function returning char b. f is a pointer to an array of function returning a charc. Invalid declarationd. f is a function returning pointer to array[] of pointer to function returning char.
Ans : d
1. A binary tree of height h, h > 0 has
a. at least h and atmost 2*h-1 elements in it. b. at least 2^h and atmost (2^h)+1 elementz in it. c. at least 2^h -1 and atmost h^2 elements in it. d. at least h and atmost (2^h) - 1 elements in it.
Ans: d
2. Thrashing is a. flooding of pages in the memory. b. increase in removal of pages from memory. c. increase in page faults leading to decrease in CPU utilization. d. removal of unused pages from memory making space for new ones.
Ans: c
3. Recursive Descent parser is a type of a. Bottom up parser. b. Top Down parser. c. None of these. d. Bottom down parser.
Ans: b
4. alloca() allocates memory from a. Heap. b. Reserved memory. c. Data segment. d. Stack.
Ans: d
5. What is the octal equivalent of decimal (5468). a. 12360. b. 12560. c. None of these. d. 12650.
Ans : c
C:
1.what is the o/p ?
void main(){ char *mess[]={"Have","a","nice","day","Bye"); printf("%d \t %d",sizeof(mess),sizeof(mess[1]));} a. 16 4b. 5 4c. 20 4d. Error answer: c
2.what is the o/p of the following programe?void main(){ int i,count=0; char *p1="abcdefghij"; char *p2="alcmenfoip";
for(i=0;i<=strlen(p1);i++) { if(*p1++ == *p2++) count+=5; else count-=3; } printf("count=%d\n",count);} a. 15b. 6c. 12d. compiler error answer: b ( note : strlen(p1) == i when i=6)
3.what does main return on successful execution?a. 1b. 0c. -1d.Nonzero answer:b
4.main(int argc,char *argv[]){ printf((argc > 1 ? "%c" : "%c",*++argv);}If the i/p string is "GESL Bangalore".a. Gb. Ec. Bd. GESL answer: c
5. How do u declare a pointer to an array of pointers to int?a. int *a[5];b. int **a[5];c. int *(*a)[5];d. u con not declare answer: c
Questions on OS:
1.UDP is aa. Reliable protocolb. Unreliable protocolc. Connectionless protocold. Both b & c Answer: d
2.Real Time OS usesa. RISC processorb. CISC processorc. SISC processord. Any of the above Answer: a
3.Race condition could be overcome usinga. A global variableb. A local variablec. Mutexd. All of the above
4.Repeaters are ina. Data link layerb. Physical layerc. Network layerd. Transport layer Answer: b
5.Telecom Networking usesa. Packet switchingb. Circuit switchingc. Message switchingd. Non of the above
Ans : b ( normally )( packet switching in ISDN )
1)what is big-endian.a) MSB at lower address LSB at higher addressb) LSB at lower address MSB at higher addressc) memory mgmt techniqued) none of the aboveans:a2)what is Little-endian.a) MSB at lower address LSB at higher addressb) LSB at lower address MSB at higher addressc) memory mgmt techniqued) none of the aboveans:b3)8086 hasa)16 bit data bus ,16 bit address busb)16 bit data bus,32 bit address busc)8 bit data bus,16 bit address busd)8 bit data bus,8 bit address busans:a4) what is the scheduling algorithm used in general operating systems.a) FCFS algorithmb) Highest Priority First algorithmc) Round-Robin algorithmd) None of the aboveans:c5)Router is present ata)Physical layerb)Data Link Layerc)Network Layerd)None of aboveans:c6)Condition for deadlock occurancea) Mutual Exclusionb) no premptionc) hold and waitd) circular waite) all of the aboveans:d7)PCI stands fora)Programmable computer Interfaceb)Peripheral Computer Interfacec)programmable Control Interfaced)Peripheral Component Interfaceans:d8)Toggle state in J-K flip-flop isa)0 1b)1 0c)1 1d)0 0ans :c9)Interrupt is serviceda)Immediatly when it occursb)After the completion of current instruction.c)Ignoredd)None of the above.ans:b
1) main(){ int a; char *p; a = sizeof(int) * p; printf("%d\n",a); }a)compile errorb)run time errorc)4d)compiler dependentans:a2)#define SIZE sizeof(int) main(){ int i=-1; if( i < SIZE ) printf("True\n"); else printf("False\n"); }a) Trueb) Falsec) can't predictd) None of theseans:b (?)
3) int (*fun())[]a) function returning a pointer to an arrayb) function returning an array of pointersc) pointer to a funtion which takes array as asrumentd) Compiler errorans: a4) main(){ int a=8,d; int *p; p=&a; d=a/*p; print("%d\n",d); }a) 1b) 0c) compiler errord) run time errorans: c5)main(){ char *a="Hello"; *a++ = 'h'; printf("%s\n",a); }a) hellob) elloc) runtime errord) compiler errorans:b6) main(){ char p[]="Hello"; p[0]='h'; printf("%s\n", p); }a) hellob) Helloc) compiler errord) run time errorans:a7)#define mysizeof(a) (&a+1) - &a main( float d; printf("%d\n", mysizeof(d) ); }note: assume sizeof float is 8 bytesa) 8b) 4c) 1d) compiler errorans:c8) main() { int *p=10; printf("%d\n",*p); }a) 10b) run time errorc) compiler errord) 5ans:b (?)
9)main(){ int i=-1; i<<=2; printf("%d\n",i); }a) -1b) -2c) -4d) 0ans:c10) main(){ int i= 0xffffffff; printf("%d\n",i); }note: size of int is 4 bytesa) -1b) 65635c) 100d) errorans:a
1. Where is the MBR stored? 1. maintained by OS 2. MBR is in Boot. 3 MBR is in First sector of HDD 4. None of the above. 2. Where is the partition table stored? 1. BIOS 2. CMOS Setup 3. MBR 4. stored per partition.3. Where is the boot record stored? 1. BIOS 2. CMOS Setup 3. MBR 4. stored per partition.4. How many primary partitions can be created? 1. 1 2. 2 3. 3 4. 4 ans : 4.
5. What is the difference between primary & extended partion? 1. Both are same 2. Primary and extended are in logical partion 3. primary cannot be subdivided but extended can be. 4. extended cannot be subdivided but primary can be. ans 3.
6. Can we create 2 primary dos partions? a)Yes b)No c)Depends on the hard Disk. d)None of the above. Ans: Yes 7. Can we create 2 extended partitions ?
a)Yes b)No c)Depends on the hard Disk. d)None of the above. Ans: No.
8. How many partitions can be created on a given harddisk? a) Depends on the size of Disk. b) 24 c)4 d)26
9. Can we hide a partition? a) Yes b) No c) Depends on the Hard Disk d) None. ans: Yes.
10. Sliding window protocol lies in which layer? 1. Transport Layer 2. network Layer 3. Datalink layer 4. Application Layer
Ans : 3. DAtalink layer
11. Which is the highest priority interrupt . 1. rst5.5 2. rst6.5 3. TRAP 4. HLD 12. 8085 is 1. 16-bit 2. 8-bit 3. 32-bit 4. 20-bit microprocessor.
Ans : 2. 8 bit
13. protected mode is present in which processor 1. 8085 2. 8086 3. 80386 4.8087 14. The no. of address lines required to address 4k of memory a)11 b)12 c) 14 d) 16 Ans: b 15) Where is CMOS setup stored a) Hard Disk b) BIOS c)CMOS Ram d) MBR.
Ans : CMOS Ram
C questions
1> int A=1,B=2; if(A==B < printf("Hello ")) printf("world\n"); else printf("Bangalore\n");
What is the o/p?
a> world b> Hello bangalore c> bangalore d> Hello world.
ans > d> Hello world.
2>
main() { int i; for(i=0; i< 10; i++) { int j=10; j++; printf("j= %d\n", j); } }
what is o/p ?
a> 10 to 19 b> error j undeclared c> 10 times 11 d> 10 - 18
ans> c> 10 times 11.
3> union test{ int a; union test *p; }; main(){ union test q; printf(" a= %d\n ", q.a); } what is o/p?
a> 0 b> syntax error c> garbage value d>run time error
ans > c
4>
register int a,b; main(){ for(a=0 ; a<5 ; a++) b++; }
a> 5 b> 4 c> 0 d> error
ans > d
5> # define dprint(expr) printf(" expr= %d \n ", expr)
main(){
int i=10,j=2;
dprint(i / j) ; }
a> 5 b > expr= 5 c> i / j= 5 d> error.
ans > b.
Operating system concepts
1> Virtual memory is
a> Infinite, user is not constrained while writing program. b> Finite it is limited by main memory + swap memory. c> Infinite ,Yes As the process needs memory it is allocated by demand paging. d> Finite ,It is limited by machines addressing capacity.
ans> d
2> Find the correct sentence
a> UNIX is monolithic MS-DOS is Microkernel b> UNIX & MS-DOS are both monolithic. c> UNIX & MS-DOS are both Microkernel. d> All are wrong. ans> b
3> In which OSI layer packet sequencing is checked
a> Physical layer b> Data link layer c> Network layer d> Transport layer
ans> d
4> In General purpose OS user cannot change which state of process.
a> premption b> sleep c> creation d> ready
ans> a
5> Which addressing scheme is not common for 8085 & 8086
a> Register addressing b> Indexed addressing c> Register Indirect addressing d> Direct addressing. Ans: b
C :
What is the output of the following :1. main() { int *p ; p=(int *)malloc(-10); }
a) allocates 0 bytesb) allocates memory, if available c) compilation errord) Runtime error
Ans) b
2. main() { for( printf("a") ; printf("b") ; printf("c") ) ; }
a) abcb) abc abc abc .....(infinite times)c) a bc bc bc ....(infinite times)d) Error
Ans) c
3. main() { int i= 10 * fun() ; printf("%d",i); }
fun() { return 10 ; }
a) 0 b) 10c) 100d) Error
Ans) c
4. int i= 10 * fun() ; main() { printf("%d",i) ; }
fun() { return 10 ; }
a) 0b) 10c) 100d) Error
Ans) d
5. Assume size of int to be 2 bytes :
main() { int i = 100 ; printf("%d ", sizeof(i++)); printf("%d ",i) ; }
a) 2 100b) 2 101c) 100 101d) 101 100
Ans) a
Computer Fundamentals :
1. Which one of the following always resides in the memory ?
a) Linkerb) Loaderc) Compilerd) All of the Above
Ans) b
2. Which of these is not a layer in OSI model ?
a) Application layerb) Network Layerc) Internet Layerd) Data Link Layer
Ans) c
3. Which one of the following data structures is best suited for searching ?
a) Arraysb) Singly Linked Listc) Doubly Linked Listd) Hash Table
Ans) d
4. Which of the following data structures is best suited for Deletion ?
a) Arrays b) Singly Linked Listc) Doubly Linked Listd) Hash Table
Ans) c
5.Which one of these is not a scheduling technique in Operating System?
a) Last-Come-First-Serve Schedulingb) First-Come-First-Serve Schedulingc) Preemptive Schedulingd) Round Robin Scheduling
Ans) a
6. Demand Paging is
a) All the pages of a process is loaded at the startb) When a single page is demanded then all other pages are also loadedc) When a page is required then only it is loaded d) None of the Above
Ans) c
7. Page Fault is
a) A page is referenced that is not in the memory .b) A page is referenced that is not in the Disk.c) A page being added to the process.d) None of the above
Ans) a
8. If the number of internal nodes in a binary tree is n , then what is the number of external nodes ?
a) n -1b) nc) n + 1d) 2n
Ans) c
9. "Banker's Algorithm" is used for :
a) Deadlock Detectionb) Deadlock Avoidancec) Deadlock Preventiond) All of the above
Ans) b
10. Which of the following is used fro designing a lexical analyser of a compiler ?
a) Finite Automatab) Push Down Automatac) Turing Machine d) None of the above
Ans) a
11. Which layer in the OSI model is responsible for End to End connectivity ?
a) Data Link Layerb) Network Layerc) Transport Layerd) Session Layer
Ans) c
(1) : TRUE */1. What is the Output of the Program ? main() { int a = 1; #define p a printf("%d %d ",a++,p++) ; } a) 1, 0 b) 2, 0 c) 1 2 d) none of the above Ans (d)2. What is the Output of the Program ? #include
11. What is the Output of the Program ? main() { void *ptr ; int a = 10 ; ptr = &a ; printf("%d",*ptr) ; } 1. error 2. 10 3. 20 4. none Ans (1)
12. What is the Output of the Program ? main() { void *ptr ; int a = 90 ; char *ptr1 = "hello" ; ptr = a ; ptr = ptr1 ; } a. executes w/o any error b. compilation error c. runtime error d.none Ans (a)
13. What is the Output of the Program ? main() { char *p = "helloo" ; char *p1 = "strcat" ; while((*(p++) = *(p1++)) != '\0') { ; } } a. error b. address is copied c. contents are copied d . none Ans (c)14. What is the Output of the Program ? int g = 10 ; main() { int a = 10 ; printf("%d",a) ; } int g ; a. 10 b. 11 c. error d. none Ans (a)15. What is the Output of the Program ? main() { int a = 1 ; int b = 0 ; a = a++ + --b * a++ ; printf("%d",a) ; } a. error b. none c. 1 d .2 Ans (d)16. What is the Output of the Program ? struct s { int si; union u { float uf; char uc; }; }; main() { printf("%d",sizeof(struct s)); } a. 8 b. 3 c. 6 @ d. 7
17. What is the Output of the Program ? struct st { int a; char b; } main() { } a. struct st is return type of main@ b. main is a variable of struct st. c. Compilation error d. Run time error Ans (A)-----------------------------------------------------18. What is the Output of the Program ? typedef struct info { int i; char b; } node; main() { struct info node1; node1.i=55; printf("%d",node1.i); } a. 55 b. Not possible to use struct info c.Compilation error d. Garbage value. Ans (A)19. What is the Output of the Program ? struct a { int i; int display() { printf("hello world\n"); } }; main() { strcut a vara; vara.display(); } a. hello b. hello world c. Compile time error d. garbage 20. What is the Output of the Program ? struct a { int (*ptr)(); }; int display() { printf("Global Edge\n"); } main() { struct a structa; structa.ptr=display; structa.ptr(); } A. Global Edge B. Address of display function C. address of structa D.Error Ans (A)21. What is the Output of the Program ? typedef int *ABC; typedef ABC XYZ[10]; int main() { XYZ var; } 1. var is an array of integer pointers. 2. var is a pointer to an integer array. Options: a) only 1 is correct. b) only 2 is correct. c) both 1 and 2 are correct. d) typedef statements are in wrong order. Answer : b
(1) : TRUE */1. What is the Output of the Program ? main() { int a = 1; #define p a printf("%d %d ",a++,p++) ; } a) 1, 0 b) 2, 0 c) 1 2 d) none of the above Ans (d)2. What is the Output of the Program ? #include
11. What is the Output of the Program ? main() { void *ptr ; int a = 10 ; ptr = &a ; printf("%d",*ptr) ; } 1. error 2. 10 3. 20 4. none Ans (1)
12. What is the Output of the Program ? main() { void *ptr ; int a = 90 ; char *ptr1 = "hello" ; ptr = a ; ptr = ptr1 ; } a. executes w/o any error b. compilation error c. runtime error d.none Ans (a)
13. What is the Output of the Program ? main() { char *p = "helloo" ; char *p1 = "strcat" ; while((*(p++) = *(p1++)) != '\0') { ; } } a. error b. address is copied c. contents are copied d . none Ans (c)14. What is the Output of the Program ? int g = 10 ; main() { int a = 10 ; printf("%d",a) ; } int g ; a. 10 b. 11 c. error d. none Ans (a)15. What is the Output of the Program ? main() { int a = 1 ; int b = 0 ; a = a++ + --b * a++ ; printf("%d",a) ; } a. error b. none c. 1 d .2 Ans (d)16. What is the Output of the Program ? struct s { int si; union u { float uf; char uc; }; }; main() { printf("%d",sizeof(struct s)); } a. 8 b. 3 c. 6 @ d. 7
17. What is the Output of the Program ? struct st { int a; char b; } main() { } a. struct st is return type of main@ b. main is a variable of struct st. c. Compilation error d. Run time error Ans (A)-----------------------------------------------------18. What is the Output of the Program ? typedef struct info { int i; char b; } node; main() { struct info node1; node1.i=55; printf("%d",node1.i); } a. 55 b. Not possible to use struct info c.Compilation error d. Garbage value. Ans (A)19. What is the Output of the Program ? struct a { int i; int display() { printf("hello world\n"); } }; main() { strcut a vara; vara.display(); } a. hello b. hello world c. Compile time error d. garbage 20. What is the Output of the Program ? struct a { int (*ptr)(); }; int display() { printf("Global Edge\n"); } main() { struct a structa; structa.ptr=display; structa.ptr(); } A. Global Edge B. Address of display function C. address of structa D.Error Ans (A)21. What is the Output of the Program ? typedef int *ABC; typedef ABC XYZ[10]; int main() { XYZ var; } 1. var is an array of integer pointers. 2. var is a pointer to an integer array. Options: a) only 1 is correct. b) only 2 is correct. c) both 1 and 2 are correct. d) typedef statements are in wrong order. Answer : b
0 Comments:
Post a Comment
<< Home