PRF 192 Full Test Bank | Answered with complete solutions What is 7/9*9 equal to? A. 2 B. 0 C. 1 D. 0.08642 What is the output when the sample code below is executed? int i=0, j=0; for( i=1; i
PRF 192 Full Test Bank | Answered with complete solutions What is 7/9*9 equal to? A. 2 B. 0 C. 1 D. 0.08642 What is the output when the sample code below is executed? int i=0, j=0; for( i=1; i<10,j<5;i*=2,j++){ j+=2; printf("%d ",j); } Printf("%d %d",i,j); A. 2 5 4 7 B. 2 5 6 4 C. 2 5 3 6 D. 2 5 4 8 E. 2 5 4 6 What is the output when the sample code below is executed? int i; for(i=1;i<4;i++) switch(i){ case 1: printf("%d ",i); break; case 2: printf("%d ",i); break; case 3: printf("%d ",i); break; case 4: printf("%d ",i); } A. 1 2 3 B. 4 C. 1 2 3 4 D. 1 2 E. 3 If the program completes executing successfully, what value should the function main returned? A. void B. 0 C. nothing D. 1 Which value can not be assigned to an unsigned-short type? A. 59876 B. 0 C. 10000 D. -3 E. 1 If a program contains just one function, then it must be___. A. clrscr() B. getch() C. printf() D. main() E. None of the other choices What number is equivalent to -4e3 ? A. -4000 B.-400 C. .004 D. -40 What does the following declaration mean ( If there are more than one correct answer, choose the best one) Int*ptr[10]; A. Array of 10 integer pointers B. Pointers to the array of 10 elements C. Array of 10 pointers. ___ is the comparison operation and ___ is the logical operation. A. Modulo, Less than B. Less than, NOT C. NOT, Less than D. Divide, OR - What is the output when the sample code below is executed? float a=14.5; double b=12.45; printf("%.6f%.6f",a,b); A. 14.50000 12.45000 B. 14.5 12.45 C. 14.500000 12.450000 D. 14.5 12.5 The ___ function after accepting a character and wait for the Enter key to be pressed. A. putch() B. putchar() C. getch() D. getchar() Evaluate the following as true or false: !(1&&0||!1) A. true B. false C. Invalid expression The precedence of operators is ___ A. Arithmetic, Comparison, Logical B. Logical, Comparison, Arithmetic C. Comparison, Arithmetic, Logical D. Comparison, Logical, Arithmetic What is the output? int main(){ char i=127; i++; printf("%d",i); return 0; } A. 128 B. -128 C. Undefined D. None of the other choices What is the output of the following code? int sum(int n); int main() { printf("s=%d\n",sum(5)); return 0; } int sum(int n) { int s,i; s=0; for(i=1;i<=n;i++) s+=i; return(s); } A. s=14 B. s=15 A user enter "pfabcd" from the console What is printed? A. pfabcd B. Runtime error C. pfa D. Blank(nothing output) E. other F. pf What is the output when the sample code below is executed? float j; j=1000*1000; printf("%3.0f",j); A. 1000000 B. error C. overflow D. 100 By default any real number is treated as A. a long double B. a double C. depends upon the memory model that you are using D. a float A string is a ___ array of characters terminated by a null('\0'). A. one-dimensional B. two-dimensional If you push 1,3, and 5 -in that odder -onto a stack , which number is popped out first? A. 5 B. 1 C. 3 Which of the following adds ones string to the end of another? A. stradd(); B. append(); C. strcat(); D. stringadd(); We want to round off x, a float, to an int value. The correct way to do so would be: A. y= (int)(x+0.5) B. y= (int)((int)x+0.5) C.y=(int) x+0.5 D. y= int(x+0.5) Which of the following is the Boolean operator for logical-and ? A. && B. & C. | D. |& Which is not a loop structure in C? A. while B. for C. do while D. repeat until Which of the following statement is (are) wrong ? (choose 2) A. a1 = 1343.44; B. 3=d; C. 3**c=d; D. cat = 'A' *** 'B'; E. asd = 'A'**24; Which of the following can be used to append one string at the end of another ? A. strcpy B. strcmp C. strcat D. None of the other choices - What is the output when the sample code below is executed ? int i; i= 1; i = i+ 2*i ++; printf("%d",i); A. 4 B. 5 C. 3 D. 1 E. 2 What is the correct format to define a value in C? A. const PI = 3.14159 B. #define PI = 3.14159 C. #define PI 3.14159 D. #define PI = 3.14159; D. #define PI 3.14159; What is required to avoid falling through from one case to the next? A. break; B. stop; C. ; D. end; Which is the correct statement about coupling? A. Coupling is a measure of the focus within a module. B. In designing, high coupling is generally acceptable. C. Global variables introduce a low degree of coupling. D. We call a module highly couple if it shares that performance with some other module including the referring module. Which of the following functions compares two strings? A. compare(); B. stringcompare(); C. cmp(); D. strcmp(); What is the correct prototype in C? A. doFunc():char; B. char doFunc() C. int doFunc(int,int); D. void doFunc(int x, int y); E. float doFunc(void); Which of the following statements prints %character? A. printf("\%") B. printf("\\%"); C. printf("\%%") D. printf("%%"); What is the output when the sample code below is executed ? #include int fn(int v){ if( v==1||v==0) return 1; if(v%2==0) return(fn(v/2)+2); else return(fn(v-1)+3); } int main(){ printf("%d\n",fn(5)); return (0); } A. 7 B. 9 C. 5 D. 6 E. 8 Which of the following data type occupied 1 byte ? (choose two) A. unsigned char B. short C. float D. long double E. double F. char What are the correct statements ? ( choose two) A. The operator ** reads as 'the data at address'. B. The *** operator is a unary operator and it returns the memory address of the operand C. The operator ** reads the address of the variable. D. The & operator is a unary operator and it returns the memory address of the operand What is the output when the sample code below is executed ? int s=0; for (int i=1;i<=10;++i){ s=s+i; if (s>=6) break; s=s+1; } printf("%d\n",s); A. 10 B. 7 C. 9 D. 8 #include #include int main(){ int i,n,a=10,b=20; for(i=0;i<10;i++){ n=a+rand()%(b+1-a); printf("%d\n",n); } return 0; } Run the above program, which is correct statement about the output? A. The following program prints 10 pseudo-random integers between 11 and 19 inclusive. B. The following program prints 10 pseudo-random integers between 10 and 20 inclusive. C. The following program prints 10 pseudo-random integers between 9 and 21 inclusive. Which are proper declarations of a string str which stores the value "Melodies" (choose two) A. char str[]= "Melodies"; B. char str[7] = "Melodies"; C. char str[9] = " Melodies"; D. char str[] = Melodies; What would happen if the user types in number 3 and presses Enter when running this program ? main(){ int x=5; char c; printf("Enter x="); scanf("%d",&x); printf("Calculate square?(Y/N):"); c=getchar(); if (c== 'Y'|| c== 'y') printf("sqr=%d",x*x); } A. sqr = 25 B. The program exits without printing the square C. sqr = 9 D. It depends on whether the user enters 'Y' or not, being asked " calculate square?" What is size of an int? A. 8 bits B. 16 bits C. Dependent on machine's "word" size D. 32 bits How is the integer pointer var declared in C? A. int** x; B. int pointer*** var; C. int pointer var; D. pointer** var; What is the output when the sample code below is executed ? void foo(int x){ if (x>0) foo(--x); printf("%d",x); } int main(){ foo(4); printf("\n"); return 0; } A. 00123 B. 001234 C. 430123 D. 01234 E. 40123 How do you include a system header file called sysheader.h in a C source file? A. #includefile B.#include C. #incl D. #incl "sysheader.h" E. #includesysheader.h What is the output when the sample code below is executed? int i=0, j=0; for(i=1;i<10,j<3;i*=2) { printf("%d",j++); } printf("%d%d",i,j); A. 012384 B. 012394 C. 0123184 D. 01283 What is the output when the sample code below is executed? void show(int**b){ printf ("%d ",**b); } int main(){ int i; int a[] = { 23,34,45,56}; for(i=0;i<3;i++) show(&a[i]+1); return (0); } A. 23 45 56 B. 23 34 45 C. 45 56 23 D. 34 45 56 Which of the following is used to call a function named as doFun() A. Call foFunc(); B. doFunc(); C. include doFunc(); D. None of other choices What is the output of the following program? void main() { Printf("%d",-5/-4); } A. -1.25 B. 1.25 C. -1 D. 1 Which one is not the standard library in C? A. time.h B. stdlib.h C. system.h D. math.h Once the function ends, the control is returned back to the ... function and execution continues from the statement immediately after the function call a. executing b.called c.declared d.calling what number is equivalent to -4e3? a.-4000 b.-400 c..004 d..0004 e.-40 what is the output when the sample code below executed? #include int fn(int v){ if(v==1||v==0) return 1; if(v%2==0) return (fn(v/2)+2); else return(fn(v-1)+3); } int main() { printf("%d\n",fn(5)); return (0); } a.6 b.9 c.8 d.7 e.5 which 2 options are correct about the function scanf? a.EOF indicates that scanf filled all addresses successfully b. scanf returns the number of addresses successfully filled of EOF c.return avoid type d.EOF indicates that scanf did not fill any address AND encountered an end of data character. what is the output when the sample code below is executed? int s=35; printf("%d%d%d",s==35,s+20,s>40) a.1 35 1 b.1 55 1 c.0 55 0 d.1 55 0 according to the standard C specification, what are the respective minimum sizes (in bytes) of the following two data type: int and long? a.2,8 b.4,8 c.2,4 d.2,2 what does the following declaration mean (if there are more than one correct answers, choose the best one) int *ptr[10]; a.array of 10 integer pointers b.pointed to the array of 10 elements c.array of 10 pointers what would happen if the user types in the number 3 and presses Enter when running this program? main(){ int x=5; char c; printf("Enter x="); scanf("%d",&x); printf("Calculate square(Y/N):"); c=getchar(); if(c==Y||c==y) printf("sqr=%d",x*x); } a.sqr=9 b.Its depend on whether the user enters 'Y' or not, being asked "calculate square?" c.sqr=25 d.the program exits without printing the square what is the output when the sample code below is executed? int i,j,k,x=0; for(i=1;i<5;i++) for(j=0;j0) printf("in C program"); a. nothing b. garbage value c. in C program d.this is a loop in C program e. this is a loop what is the output when the sample code below is executed? #include void main(){ int i,j=25; int *pi, **pj=&j; ***pj=j+5; i=*pj+5; pi=pj; **pi=i+j; printf("%d%d",**pi,pj);} a.30 35 b.65 65 c.60 60 d.25 30 e.60 65 which one of the following is a valid function definition? a. double funct(int a,b, double c,d) b. double funct(int a,b, double c) c. double funct(char a,b, double d) d. double funct(int a,int b, double c) what is the output when the sample code below is executed? char mess[]="Your are welcome here"; char *p; p=mess; mess[8]='\0'; puts(++p); a.our are wel b.our are c.Your are d.Your are wel which of the following can be used to append one string at the end of another a.strcpy b.strcmp c.strcat d.none of the above what is the output when the sample code below is executed? int a=8, b=9; if(a%2=b%3) printf("\n%d %d", ++a, b--) a. 8 9 b. 9 9 c.9 8 d. compiler error e. 8 8 what will be printed when the sample code below is executed? char **buffer="0123456789"; char **ptr=buffer; ptr+=5; printf("%s\n",ptr); printf("%s\n",buffer); a. 56789 0123456789 b.56789 56789 c.0123456789 0123456789 d.5123456789 5123456789 e.0123456789 56789 in myfile.c does not exist, what will be output of this program? #include main(){ FILE *fi; fi=fopen("myfile.c","r"); if(fi=NULL) {puts("file is not opened"); exit(1);} else puts("FILE opened");} a. file is not opened b.no output c.FILE opened d.error given the below code int a=1; int i=7; if(a||i++) i++; printf("%d",i); what is the output a.7 b.8 c.9 d.other a string is a ... array of characters terminated by a null('\0') a.one-dimensional b.two-dimensional referring to the sample code below, what value will the variable counter have when completed int x=3, counter = 0; while(x-1){ ++counter; x--;} a.4 b.2 c.3 d.0 e.1 the operation between float and int would give the result as a. float b. int c. unsigned int d.none of the above what is the output when the sample code below is executed? int k=0x55; printf("\n%d",k); printf("\n"); a.65 b.75 c.55 d.85 what is the output when the sample code below is executed? int calc(int a, int b){ int x,y; x=a+b; y=a*b; return(x+y); } int main(){ int p=3, q=4, r, s; r=calc(p,q); s=calc(q,p); printf("\n%d%d",r,s); return 0;} a. 3 4 b. 17 19 c. 18 18 d. 17 17 e.19 19 which of the following statement are true with regards to the || operator?(select al correct answer) a.this operator is used to combine two conditional expressions which evaluate to true as a whole only if either of the two expressions evaluate to true. b.only if both the expressions evaluate to false, the outcome is false c.if one of the conditional expressions return false, the outcome is false d.this operator is used to combine two logical expressions which evaluate to true if both individual expression are true what is the output when the sample code below is executed, assuming int data type is 32 bits in size? printf("%d, %d, %d, %d", sizeof(char), sizeof(int), sizeof(10.0), sizeof(10.0f)); a. 2,4,8,4 b. 1,10,10,10 c. 1,4,8,4 d. 1,4,4,4 e. 1,2,4,4 what is the output when the sample code below is executed? int a[5]={0}, x=2111223; while(x>10){ a[x%10-1]++; x/=10;} printf("%d",a[1]); a.6 b.3 c.1 d.2 what will the code below print when executed? double x=-3.5, y=3.5; printf("%.0f:%.0f\n",ceil(x), ceil(y)); printf("%.0f:%.0f\n",floor(x), floor(y)); a -3:3 -4:4 b.-4:3 -3:4 c.-4:4 -3:3 d.-3:4 -4:3 e.-4:3 -4:3 consider the following code: if(a==b) printf("\n the number are equal"); else(a
Last updated: 1 year ago
Preview 1 out of 44 pages