Vous êtes sur la page 1sur 14

Paper: Global Edge Placement Paper (Technical- C & Data Structure) C Paper 1.

What is the output of the following code ? int main( ) {for( ; ;); printf("Hello\n"); return 0; } Runs in an infinite loop without printing anything.

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; } Both print different values. 3. Output of the code? int main() { char a[] = "world"; printf("%d %d\n",strlen(a),sizeof(a)); return 0; } ans:5,6 4. What is the output generated? main() { char *s = "Hello"; printf("%s",1(s)); } ans:ello

5. Interpret the given declaration char ( * ( f ( ) ) [ ] )( ) Ans:f is a function returning pointer to array[] of pointer to function returning char. Data Structure: 1. A binary tree of height h, h > 0 has ans: at least h and atmost (2^h) - 1 elements in it. 2. Thrashing is ans: increase in page faults leading to decrease in CPU utilization. 3. Recursive Descent parser is a type of Ans: Top Down parser. 4. alloca() allocates memory from ans: Stack. 5. What is the octal equivalent of decimal (5468). ans None of these.
PAPER: Global Edge Placement Paper2 (Technical-C & Fundamentals) 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? Ans : 4. 5. What is the difference between primary & extended partition? ans: primary cannot be subdivided but extended can be. 6. Can we create 2 primary dos partitions? Ans: Yes . Can we create 2 extended partitions ? Ans: No.

8. How many partitions can be created on a given hard disk? a) Depends on the size of Disk. b) 24 c)4 d)26 9. Can we hide a partition? Ans: Yes. 10. Sliding window protocol lies in which layer? Ans : 3. Data link layer 11. Which is the highest priority interrupt . 1. rst5.5 2. rst6.5 3. TRAP 4. HLD 12. 8085 is Ans : 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 Ans: 12 15) Where is CMOS setup stored Ans : CMOS Ram

16) main(){ int a; char *p; a = sizeof(int) * p; printf("%d\n",a); } ans:compile error


17)#define SIZE sizeof(int) main(){ int i=-1; if( i < SIZE ) printf("True\n"); else printf("False\n"); } ans: False 18) int (*fun())[] ans: function returning a pointer to an array

19) main(){ int a=8,d; int *p; p=&a; d=a/*p; print("%d\n",d); } ans) compiler error 20)main(){ char *a="Hello"; *a++ = 'h'; printf("%s\n",a); } ans :ello 21) main(){ char p[]="Hello"; p[0]='h'; printf("%s\n", p); } ans) hello 22)#define mysizeof(a) (&a+1) - &a main( float d; printf("%d\n", mysizeof(d) ); } note: assume sizeof float is 8 bytes ans) 1
23)

main() { int *p=10; printf("%d\n",*p); } ans) run time error 24) main(){ int i=-1; i<<=2; printf("%d\n",i); } ans) -4 26) main(){ int i= 0xffffffff; printf("%d\n",i); } note: size of int is 4 bytes ans) -1

Paper: Global Edge Placement Paper (Technical- C Section)


C Paper 1. main() { int i; i=(2,3); printf("%d",i); } ans : 3 2. main(){ char str[]="GESL"; printf("%d %d",sizeof(str),strlen(str)); } ans: 5, 4 3. main(){ for(i=0;i++;i<100) printf("hello world\n"); } ans: 0 times. 4. main(){ for(i=1;i++;i<100) printf("hello world\n"); } ans: infinite loop 5. main(){ char c; scanf("%s",c); } ans: Compiler dependent. 6. main(){ int k=5; for(++k<5 && k++/5 || ++k<8); printf("%d\n",k); } 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); } Ans: Bug in the code. 8). int main() { int i = 10, j ; if ( ( j = ~i ) < i ) printf ( "True" ) ; else printf ( "False" ) ; } 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) ); } Ans:4 11. main() { int a=10,20; a^=b^=a^=b; printf("%d\n %d\n",a,b); 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 "); } } Ans : Hello World Hello World 13. main() { char str1[]="Hello"; char str2[]="Hello"; if ( str1==str2 ) printf("True\n"); else printf("False\n"); } Ans: False. 14. main() { # include <stdio.h> int i = 10 ; printf("%d\n", i/2 ); } ans : 5 15. #include <stdio.h> # 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

GLOBAL EDGE Placement Question Paper


main() { int arr[]={ 1,2,3,4 }; int *ptr ;;;; ptr++ = arr; printf("%d,%d",ptr[2],arr[2]); return 0; } ans : lvalue required for ptr;

2> main() { char s[10]; scanf ("%s",s); printf(s); } ans : prints abcd. 3> main() { char c = 255; printf ("%d",c); return 0; } ans b: prints -1. 4> main() { int i; for (i=7;i<=0;i--) printf ("hello\n"); } ans : prints nothing. 5> main() {printf( printf ("world") );} ans : compiler error. computer concepts 1> A c source code file can be ans c : both compiled and interpreted 2> c prigramming approach is ans :top down approach 3> The access time is less for ans :registers

4>resolving of external variables in a program is done at ans : link time. 5> interrupts inform process about ans : events external to process asynchronously /* C question and answers All questions are tested in Turbo C compalier and have not been tested in gcc or ( linux platform) */ 1) #include main() { scanf("%d"); printf(); } which of the following is correct? ans)compilation error 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++)); } ans : AFE( macro substitution 3 times) 3)#include main() { 200; printf("tricky problem"); } ans)warning message 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 ? ans)printf(const char *p,...); /* questions on computer concepts */ 1)which of the following is not a system file? a).sys b).com c).ini d)none

ans : d

2)A magnetic tape is equivalent to which of the following structure? a)Graphs b)trees c)Lists d)Dictionaries ans : c

3)For a linked list implementation which searching technique is not applicable? a)linear search b)none c)quick sort d)binary search ans : d 4)Encryption and decryption is done in which layer? a)DLL b)Network layer c)transport layer d) Presentation layer ans : d

5)which of the following is not performed by the OS? a)cpu scheduling b)memory management c)Transaction d)none ans : c
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ? A. B. C. D. rem = 3.14 % 2.1; rem = modf(3.14, 2.1); rem = fmod(3.14, 2.1); Remainder cannot be obtain in floating point division.

Answer & Explanation

Answer: Option C Explanation: fmod(x,y) - Calculates x modulo y, the remainder of x/y. This function is the same as the modulus operator. But fmod() performs floating point divisions. Example:

#include <stdio.h> #include <math.h> int main () { printf ("fmod of 3.14/2.1 is %lf\n", fmod (3.14,2.1) ); return 0; }
Output: fmod of 3.14/2.1 is 1.040000 View Answer Online Compiler Report Discuss in Forum 2. What are the types of linkages? A. C. Internal and External External and None B. D. External, Internal and None Internal

Answer & Explanation

Answer: Option B Explanation: External Linkage-> means global, non-static variables and functions. Internal Linkage-> means static variables and functions with file scope. None Linkage-> means Local variables. View Answer Online Compiler Report Discuss in Forum

3.

Which of the following special symbol allowed in a variable name? A. C. * (asterisk) - (hyphen) B. D. | (pipeline) _ (underscore)

Answer & Explanation

Answer: Option D Explanation: Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted. Names must not begin with a digit. Examples of valid (but not very descriptive) C variable names: => foo => Bar => BAZ => foo_bar => _foo42 => _ => QuUx View Answer Online Compiler Report Discuss in Forum 4. Is there any difference between following declarations? 1 : extern int fun(); 2 : int fun(); A. B. C. D. Both are identical No difference, except extern int fun(); is probably in another file

int fun(); is overrided with extern int fun();


None of these

Answer & Explanation

Answer: Option B Explanation:

extern int fun(); declaration in C is to indicate the existence of a global function and it is
defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the current
module or in the same file. View Answer Online Compiler Report Discuss in Forum 5. How would you round off a value from 1.66 to 2.0? A. C. ceil(1.66) roundup(1.66) B. D. floor(1.66) roundto(1.66)

Answer & Explanation

Answer: Option A Explanation:

/* Example for ceil() and floor() functions: */

#include<stdio.h> #include<math.h> int main() { printf("\n Result : %f" , ceil(1.44) ); printf("\n Result : %f" , ceil(1.66) ); printf("\n Result : %f" , floor(1.44) ); printf("\n Result : %f" , floor(1.66) ); return 0; } // Output: // Result : 2.000000 // Result : 2.000000 // Result : 1.000000 // Result : 1.000000

6.

By default a real number is treated as a A. C. float long double B. D. double far double

Answer & Explanation

Answer: Option B Explanation: In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265... When the accuracy of the floating point number is insufficient, we can use thedouble to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space. View Answer Online Compiler Report Discuss in Forum 7. Which of the following is not user defined data type? 1: struct book { char name[10]; float price; int pages; };

2:

long int l = 2.35;

3:

enum day {Sun, Mon, Tue, Wed};

A.

B.

C.

D.

Both 1 and 2

Answer & Explanation

Answer: Option B Explanation: C data types classification are 1. Primary data types 1. int 2. char 3. float 4. double 5. void 2. Secondary data types (or) User-defined data type 1. Array 2. Pointer 3. Structure 4. Union 5. Enum So, clearly long int l = 2.35; is not User-defined data type. (i.e.long int l = 2.35; is the answer.) View Answer Online Compiler Report Discuss in Forum 8. Is the following statement a declaration or definition?

extern int i;
A. C. Declaration Function B. D. Definition Error

Answer & Explanation

Answer: Option A Explanation: Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i) Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference". View Answer Online Compiler Report Discuss in Forum 9. Identify which of the following are declarations 1 : extern int x; 2 : float square ( float x ) { ... } 3 : double pow(double, double); A. C. 1 1 and 3 B. D. 2 3

Answer & Explanation

Answer: Option C Explanation: extern int x; - is an external variable declaration.

double pow(double, double); - is a function prototype declaration. Therefore, 1 and 3 are declarations. 2 is definition. View Answer Online Compiler Report Discuss in Forum 10. In the following program where is the variable a getting defined and where it is getting declared?

#include<stdio.h>
int main() { extern int a; printf("%d\n", a); return 0; } int a=20; A. B. C. D.

extern int a is declaration, int a = 20 is the definition int a = 20 is declaration, extern int a is the definition int a = 20 is definition, a is not defined a is declared, a is not defined

Answer & Explanation

Answer: Option A Explanation: - During declaration we tell the datatype of the Variable. - During definition the value is initialized.

11. When we mention the prototype of a function? [A]. [C]. Defining Prototyping [B]. [D]. Declaring

Calling

Answer: Option B Explanation: A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function's name, argument types and return type. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.

I request Electronics and communication ENGINEERING students to visit my blog for more abhishek1ek.blogspot.com awhengineering.blogspot.com

Vous aimerez peut-être aussi