ENG 3211-UCF

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Which header file should be included to use the pow() function?

#include <math.h>

What is the output of the following program? #include <stdio.h>int main(void) { for(int col=1;col<10;col++){ for(int row=1;row<col;row++){ printf("* "); } printf("\n"); } return 0;}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

What is the output of the following program? #include <stdio.h>int main(void) { for(int col=1;col<10;col++){ for(int row=1;row<5;row++){ printf("* "); } printf("\n"); } return 0;}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

#include <stdio.h>int main(void) { for(int col=1;col<10;col++){ for(int row=10;row>col;row--){ if(row%2==0) printf("* "); } printf("\n"); } return 0;}

* * * * * * * * * * * * * * * * * * * * * * * * *

What is the output of the following program? #include <stdio.h>int main(void) { for(int col=1;col<10;col++){ for(int row=10;row>col;row--){ printf("* "); } printf("\n"); } return 0;}

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

What does the following program print? #include <stdio.h> int main( void ) { int count = 1; while ( count <= 5 ) {printf( "%s\n", count % 2 ? "0000" : "1111" ); (++count)+2; } return 0;}

0000 1111 0000 1111 0000

What does the following program print? #include <stdio.h>int main( void ){ int count = 1; while ( count <= 5 ) {printf( "%s\n", count % 2 ? "0000" : "1111" );(++count)+2; } return 0;}

0000 1111 0000 1111 0000

What does the following program print? #include <stdio.h> int main( void ) { int count = 1; while ( count) { printf( "%d\n", count );count=0; } return 0;}

1

What is the output of the following program? #include <stdio.h>int main( void ){ int count1 = 1, count2 = 2;if ("0") {if (0) {printf( "%d\n", count1+1 );}else {printf("%d\n", count2-1 );}count1=0; }return 0;}

1

Which line number in the following program contains an error? 1. #include stdio 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. printf( "Welcome to C!\n" ); 7. } // end function main

1

What is the output of the following program? #include<stdio.h>main(){int i = 1;while(i){printf("%d",i++);if(i==3) break;if(i<=5) continue;}}

1 2

How to fix the error(s) in the following program? (if any) (Multiple answer) 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. printf( "Welcome to C!\n" ); 7. // end function main

1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void )5. { 6. printf( "Welcome to C!\n" ); 7.} // end function main

The data type of an object in memory determines ......

1. what operations that can be performed on it 2. the size of the required memory for the data 3. the set of values it can have

What is the output of the following program? #include <stdio.h> int main( void ) { int count1 = 1, count2 = 2; if ("0") { {int count1 =count2+5;count1++; printf( "%d\n", count1+count2 );} } return 0; }

10

What is the output of the following program? #include <stdio.h>int main( void ){ int count1 = 1, count2 = 2;if ("0") {{int count1 =count2+5;count1++; printf( "%d\n", count1+count2 );}}return 0;}

10

What is the first line of code that contains an error? 01) #include <stdio.h> 02) int myPower(int base, int exp) 03) 04) int main(void) 05) { 06) printf("%d raised to the %d power is %d\n", 2, 10, myPower(2,10)); 07) 08) return -1; 09) } 1 0) 11) int myPower (int base, int exp) 12) { 13) int answer = 1; 14) 15) for (int i = 1; i <= exp; i++) 16) answer = answer * base; 17) 18) return answer; 19) 20) }

11

What is the output of the following program? 01. #include <stdio.h> 02. int main( void ) 03. { 04. int count = 10; 05. if (2>1) { 06. if (-1) {printf( "%d\n", count+1 );} 07. else {printf("%d\n", count-1 );} 08. count=0; 09. }1 0. return 0; 11. }

11

What is the output of the following program? 01. #include <stdio.h> 02. int main( void ) 03. { 04. int count = 10; 05. if (2>1) { 06. if (-1) {printf( "%d\n", count+1 );} 07. else {printf("%d\n", count-1 );} 08. count=0; 09. } 10. return 0; 11. }

11

What will be the output of the following snippet if n=1? c) switch ( n ) { case 1: printf( "1" ); case 2: printf( "2" ); break; default:printf( "3" ); break; }

12

What will be the output of the following snippet if n=1? c) switch ( n ) {case 1: printf( "1" );case 2: printf( "2" );break; default:printf( "3" );break;}

12

What is the output of the following code? #include <stdio.h> int main(void) { int a=1, b=2, c=3; printf("%d%d\n%d\n", a,c,b); return 0;}

13 2

What is the output of the following code? #include <stdio.h> int main(void) { int a=1, b=2, c=3; printf("%d%d%d\n", a,c,b); return 0;}

132

How many A's will be printed and how many B's will be printed with the following code snippet? i=0; while (i<5 ){ printf("A "); i+=3;} while (i<7) {printf("B "); i+=2;}

2 A's and 1 B's

How many A's will be printed and how many B's will be printed with the following code snippet? i=0;while (i<5){ printf("A ");i+=3;} while (i<7){printf("B ");i+=2;}

2 A's and 1 B's

What will be the output of the following snippet ? int counter=20; do { if ( counter % 2 == 0 ) { printf( "%d,", counter ); } counter += 2;} while ( counter > 100 );

20

What does the following program do? #include "stdio.h"int main(void) { int i=20; do { if ( i % 2 == 1 ) break; i += 2; printf( "%d ", i ); } while ( i > 50 ); return 0;}

22

What is the output of the following program? #include <stdio.h>int main( void ){ int count = 2; while ( count <= 3 ) { while ( count < 4 ) {printf("%d", count ); ++count; } }return 0;}

23

What is the output of the following program? #include <stdio.h>int main( void ){ int count = 2; while ( count <= 3 ) {while ( count < 4 ) {printf("%d", count );++count; } }return 0;}

23

What is the value of a printed to the console by the following code? #include <stdio.h> int foo(int a); int bar(int b); int main(void) { int a = 3; a = foo(a); printf("The value of a is: %d\n", a); return 0; } int foo(int a) { a = a + 2; return bar(a); } int bar(int a) { return a * 5; }

25

Which line number in the following program contains an error? 1. #include <stdio.h> 2. 3. / function main begins program execution 4. int main( void ) 5. { 6. printf( "Welcome to C!\n" ); 7. } // end function main

3

What is the output of the following program? #include <stdio.h> int main(void) { int n = 1; { int n = 2; { auto int n = 3; printf("%d", n); } printf("%d", n); } printf("%d\n", n); }

321

What is the output of the following program? #include <stdio.h> int main(void) { int n = 1; { n = 2; { n = 3; printf("%d", n); } printf("%d", n); } printf("%d\n", n); }

333

Count the number of the statements in the following code: #include <stdio.h> // function main begins program executionint main( void ) {int A=1,B=2,C=3; A=B+1; B=A+1 ;printf( "%d", A+B);} // end function main

4

In which line the first error is appeared (if any)? 1. #include <stdio.h>2. int main(void) {3. printf("Welcome. Please enter your Zipcode.\n");4. zipcode=32766;5. int zipcode;6. if (zipcode > 32715 && zipcode < 3400) 7. printf(" Please Visit our website, next Monday.");8. return 0;9. }

4

What is the output of the following code? #include <stdio.h> int main( void ){ int i=2,j=3,x=1; if (i>0) { if(j>i){ x=j; x=j+1; printf("%d", x++); } else{ printf("%d",i); } } return 0;}

4

What is the output of the following code? #include <stdio.h>int main( void ){ int i=2,j=3,x=1;if (i>0) {if(j>i){x=j;x=j+1;printf("%d", x++);}else{printf("%d",i);} }return 0;}

4

Which line number in the following program contains an error? 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main 5. { 6. printf( "Welcome to C!\n" ); 7. } // end function main

4

How many times is the statement inside the for loop being run ? int timesRan = 0; while (timesRan<10){timesRan+=2;}

5

What is the value of a that is printed to the console by the following code? #include <stdio.h> void foo(int a); int main(void) { int a = 5; foo(a); printf("The value of a is: %d\n", a); return 0; } void foo(int a) { a = a + 2; return; }

5

What is the output of the following code if the user enters 5 and 6 in order using a keyboard? #include <stdio.h> int main(void) { int a=1, b=2, c=3;scanf("%d%d",&a,&c); printf("%d%d\n%d\n", a,a+c,b+a); return 0;}

511 7

What is the value of c after the following snippet: int c=3, product=2; while ( c <= 5 ) { ++c; product *= c;}

6

What is the value of c after the following snippet: int c=3, product=2; while ( c <= 5 ) { ++c; product *= c;}

6

Which line number in the following program contains an error? 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. printf( "Welcome to C!\n" ) 7. } // end function main

6

Which <math.h> function rounds x to the smallest integer not less than x?

ceil(x)

Which of the following functions are in the C standard math library?

cos() sin() pow()

Which of the following are types of scope that an identifier can have? a) file b) block c) register d) function e) extern f) static

d a b

Which of the following are not storage class specifiers? a) auto b) block c) register d) file e) extern f) static

d b

Which on of the following is a legal identifier in C programming?

different: legal a_variable: legal 2ndvar: illegal intrer_21: legal test: illegal

What is the output of the following program if the user enter 25, (age =25). #include <stdio.h>int main( void ) { int age, ageRange;printf(" Please enter your age to see the consered discount for you. ");scanf("%d", &age);if (age<18) ageRange=1;else if (age>=18 && age< 30) ageRange=2;else if (age>=30 && age<50) ageRange=3;else if (age>=50 && age<65) ageRange=4;else ageRange=5;switch(ageRange){case 1:printf("discount 10 Percent.\n");break;case 2:printf("discount 15 Percent.\n");case 3:printf("discount 20 Percent.\n");break;printf("discount 25 Percent.\n");case 4:default:printf("discount 50 Percent.\n");break;}return 0;}

discount 15 Percent. discount 20 Percent.

What is the output of the following code: #include <stdio.h>void sub(int a, int b);int main(void) { printf("%d", sub(3,2));return 0;}void sub(int a, int b){ return a+b;}

error

Let f(x)=−x2+6x−6 for 1≤x≤5. Answer the following questions.

f(1) = f(5) = -1. :True f is continuous on [1 , 5]. :True f is differentiable on (1 , 5). :True There exists at least one minimum or maximum on (1 , 5). :True

Which <math.h> function rounds x to the largest integer not greater than x?

floor(x)

Modules in C are called ______________.

functions

What is the output of the following snippet? For ( x = 100, x >= 1, x++ ) printf( "%d\n", x );

infinite loop

What will be the output of the following program ? #include "stdio.h"int main(void) { int i=21; do { printf( "%d ", i ); i += 1; if ( i % 2 == 1 ) continue; } while ( i< 100 ); return 0;}

list of integers from 21 to 99 (inclusive)

Which of the following identifier names are invalid?

long 10sdigit total$amount

Which of the following are reserved keywords and can not be used for identifier names?

long, while

Which of the following is not a valid function name?

my4Power

Match the followings:

y=++x: y=x++: is a short cut for y=x;x=x+1. x is evaluated before it is incremented.

Write a single C statement to accomplish the following: Assign the sum of x and y to z and increment the value of x by 1 after the calculation.

z=(x++)+y;

Which of the following is a logical OR operator?

||

Which line number(s) in the following program contain(s) an error? (Multiple answer) 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. int x=2; y=3, z=x+y; 7. 8. Printf( "Welcome to C!\n" ); 9. }// end function main

6,8

Which line number in the following program contains an error? 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. int x=2, 7. printf( "Welcome to C!\n" ); 8. }// end function main

6: error 7: no error 1: no error 4: no error

What number is printed to the console when the following program is run? #include <stdio.h> int foo(int, int); int main(void) { printf("%d\n", foo(5,7)); return 0; } int foo(int a, int b) { return (a > b) ? a : b; }

7

How many bits (binary digits) are there in one byte?

8

Which line number in the following program contains an error? 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. int x=2, y=3, z=x+y; 7. 8. printf( "Welcome to C!\n ); 9. }// end function main

8

Which operator listed below has right to left associativity?

=

Which operator listed below has the lowest precedence?

?:

What does the following program do? #include <stdio.h>int main( void ){int x;int y;int i;int j;printf( "Enter two integers in the range 1-20: " );scanf( "%d%d", &y, &x );for ( i = 1; i <= y; i++ ) {for ( j = 1; j <= x; j++ ) {printf( "*" );}printf( "\n" ); } return 0;}

A square of * (y rows, x columns)

Which logical unit of computer architecture typically performs calculations and comparisons?

Arithmetic and logic unit (ALU)

What will be the output of the following snippet if value=101? switch ( value % 2 ) {case 0:printf( "Odd integer\n" );case 1: printf( "Even integer\n" ); }

Even Integer

What will be the output of the following snippet if value=101? switch ( value % 2 ) {case 0: printf( "Odd integer\n" ); case 1: printf( "Even integer\n" ); }

Even integer

The break statement is required in the default case of a switch selection statement.

False

The compiler will always store variables with the "register" storage class in a register of the CPU or cache memory.

False

The default case is required in the switch selection statement.

False

Write a statement or a set of statements to accomplish the following tasks: Calculate the value of 2.5 raised to the power of 3 using the pow function. Print the result with a precision of 2 in a field width of 10 positions. Answer: Printf("%10.2f", pow(3,2.5));

False

Write a statement or a set of statements to sum the odd integers between 1 and 99 using a for statement. Answer: for(int i=1;i<=99;i++) sum+=2i+1;

False

What is the output of the below code snippet? #include <stdio.h> main() { for(;;)printf("Hello"); }

Infinite loop

What is the output of the below code snippet? #include <stdio.h> main() { for(;;)printf("Hello"); }

Infinite loop

What is the output of the following program? #include <stdio.h> // function main begins program execution int main( void ) { printf( "\\Welcome to \"C!\"\\" ); } // end function main

\Welcome to "C!"\

What is being printed by the following snippet of code? int a = 4; if (a = 5) printf("a is 5"); elseprintf("a is 4");

a is 5

What type of programming language uses generally uses only 0's and 1's for writing programs?

Machine Language

Which logical unit of computer architecture typically stores information for rapid access and generallycontains volatile information that is lost when the computer is powered off?

Memory Unit

Let f(𝑥)=𝑥3. Find the second Taylor polynomial 𝑃2(𝑥) about 𝑥0=1.

P2(x)=3+3(x−1)+3(x−1)^2

Identify the following computer devices as either input or output units:

Printer: Output Keyboard: Input Monitor: Output Mouse: Input

Which logical unit of computer architecture is generally used for long term storage of information?

Secondary Storage Unit (Hard disk, CD,...)

Structured programming has shown that all C programs can be written using what forms of control?

Selection, Iteration, Sequence

Which of the following is not part of a function prototype?

The function's code

What does the following program print? 1. #include <stdio.h> 2. int main( void ) 3. { 4. int x = 1, 5. total = 0, y; 6. while ( x <= 3 ) { 7. y = x * x; 8. total += y ;9. ++x; 10. } 11. printf("Total is %d\n", total); 12. return 0; 13. }

Total is 14

What does the following program print? 1. #include <stdio.h> 2. int main( void ) 3. { 4. int x = 1, 5. total = 0, y; 6. while ( x <= 3 ) { 7. y = x * x; 8. total += y; 9. ++x; 10. } 11. printf("Total is %d\n", total); 12. return 0; 13. }

Total is 14

A C program can only use functions from the standard library or user-defined functions but not both in the same program.

True

In the C programming language, all arguments to functions are pass by value, and not pass by reference.

True

Is the following function prototype valid, that is to say, does it contains valid syntax? double foo(int a , int);

True

What is the output of the following program? #include <stdio.h> // function main begins program execution int main( void ){ printf( "Welcome\nto\nC!\n" ); } // end function main

Welcome to C!

What is the output of the following code. 1. #include <stdio.h> 2. 3. // function main begins program execution 4. int main( void ) 5. { 6. printf( "Welcome to" );printf( "C!\n" ); 9. }// end function main

Welcome toC!


Kaugnay na mga set ng pag-aaral

Post Test: American Literature Through the Eighteenth Century

View Set

ECO 232 Quiz: Chapter 2, ECO mid term

View Set

Chapter 20: Agency and Liability to Third Parties

View Set

Type of life insurance policies - FL Life Insurance

View Set