RE: [C n CPP Assist] Quick Help:'C' questions from an Electronic company
"Jaime Stuardo" <jstuardo-o7tR/[email protected]> Fri, 11 Feb 2005 12:05:02 -0400
| Newsgroups | gmane.comp.lang.c.general,gmane.comp.programming.cppug |
|---|---|
| Message-ID | <E61E591A74E42E48A7D8C7622E8A64F301BF945C@srv-security117.empresas.security.cl> |
This list isn't named "do my homework". Don't be lazy and do it yourself. Jaime -----Mensaje original----- De: khem metre [mailto:khhem9-/[email protected]] Enviado el: Viernes, 11 de Febrero de 2005 10:56 Para: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; khhem9-/[email protected] Asunto: [C n CPP Assist] Quick Help:'C' questions from an Electronic company Hello friend , following are the C questions asked in an electronic company. Please answer the questions with description: 1). What is the value of X after the execution of follwing program on a machine that uses 16 bit integers? int x=0x8000; x>>=1; a) ox4000 b) 0xc000 c) 0x0 d) None of the above 2). On a perticular machine a C compiler implements 16 bit integerts and 8 bit characters. int a[10]; char *b; int *c, *d; b=(char *) a; c=a; b=b+4; d=(int *)b; c++; what are data items to which b and c are pointing now? a) a[4] and a[1] b) a[2] and a[1] c) a[4] and a[2] d) a[5] and a[2] 3) Which is the correct output for follwing program:- unsigned int a=6; int b= -20; ( a + b > 6 ) ? puts(">6") : puts("<=6"); a) >6 b) <=6 c) >6 and <=6 d) none of the above 4) A program needs to use a value of PI (i.e. 3.1400) in calculation. How would you declare value of PI using a macro? Note that highest possible resolution is desired. 5). following C code uses a keyword interrupt to define an ISR . comment on the code. interrupt double compute_area(radius) double radius; { double area=PI * radius * radius; return area; } 6) Each of the alphabets stand for one digit, in the following sum. Find the values for each of the alphabets. Indicate the logic used. F O R T Y + T E N + T E N ----------------------- S I X T Y ----------------------- 7) following are some valid instructions for a hypothetical microcontroller which result in loading the accumulator by 0. Which of these is most efficient? i. mov a,0 ii. xor a,a iii. mul a,0 iv. sub a,a a) i b) ii c) iii d) iv 8) Two programs develop 2 program modules a.c and b.c independently which are linked together. File- a.c contains following code:- static char a, b; main() { fcall(); printf (" a=%d b=%d \n ", a , b); } File- b.c contains following code:- extern int a,b; void fcall() { a=10; b=20; } Which of the following is the likely output of the program. a) a=10 b=0 b) a=10 b=20 c) a=0 b=20 d) None as the linker would indicate an error 9) Which of the following expression evaluations would be most efficient? i. a=a*10; ii. a=a*8+a*2; iii. a=a<<3 + a<<1; iv. a=a<<3 + a+a; a) i b) ii c) iii d) iv 10) int a,b,c; long d; Which of the following expressions evaluate the result with minimum loss of resolution. i. d=a/b*c; ii. d=(long)a*c/b; iii. d=(a/b)*c; iv. d=(a*c)/b; a) ii b) iv c) ii and iv d) i 11) Is the following piece of code incorrect ? If incorrect rectify the errors. long percent (a,b) long a,b; { long d; d=(a*100)/b; return d; } main() { int marksob , per, total; total=1400; scanf( " enter the marks obtained ", marksob); per=percent(marksob, total); printf("percentage is %3d.%2d \n",per/100, per%100); } 12) using vatiable a, give definations for following:- example :- 1) An integer Answer: int a; 2) A pointer to an integer 3) an array of 10 integers 4) An array of 10 pointers to integers 5) A pointer to an array of 10 integers 6) A pointer to a function that takes an integer as an argument and returns an integer 7) An array of ten pointers to functions that take an integer argument & return an integer. 13) write a C function in a program to decide whether the year is a leap year or not. Note:- optimize the function for execution time efficiency. 14) A 100 Km long highway has 1 milestone after every Km. Total how many milestones are there? 15) Convert following C program fragment into any of the assembly languages you know: Note that a and b are character variables, and c is an integer variable. if (a) d++; else if (c) d - -; else d=0; __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo Yahoo! Groups Links