CS 223 final exam

Ace your homework & exams now with Quizwiz!

The function 'fscanf' does NOT return anything.

False

Block of code in C is designated by:

Open and close curly braces { }

Assume the user is using the keyboard to enter first and last name in one line, like: Joe Smith. Which one of the following functions will do the job? A. scanf B. gets C. both A and B

B

What data type is used to represent an exact amount of gas in your car's tank? A. integer B. Double C. Character D. None of the above

B

Which of the following assignment statements will get a double type variable from a user and place the value into the forth location of an array declared as my_array[12] ? A. scanf("%lf", &my_array[4]); B. scanf("%lf", &my_array[3]); C. scanf("%lf", my_array[5]); D. scanf("%lf", my_array[3]);

B

Which one of the followings declares a pointers to a file? A. FILE john; B. FILE *jack; C. int *FILE joe; D. pointer FILE *joe;

B

The following code reads from a file, what does one line of this file looks like? while (fscanf (infile, "%s %d %d %lf %s", aa, &pr, &ty, &rr, tt) = = 5) A. dark 66 66.6 77.7 strong B. John 66 66 77.7 88 C. Apple 66 66 77.7 Microsoft D. None of the above

C

Which of the following expressions will evaluate to 25? a) 3 + 15%7 + 7%4 b) 40/2 + 20%4 c) 100/5 + 125%20 d) 5%5 - 20%5 e) None of the above

C

Which operator is used to access the structure's member? A. - B. = C. . D. ->

C

what is the correct way to pass an array of structure named str1 with 10 elements to function foo? A. foo (str1[0]); B. foo (&str1[10]); C. foo (str1, 10); D. None of the above

C

Type of function depends on the arguments of the function.

False

When passing an array to a function, you must pass every individual element of the array to that function

False

assume complete code. The following code is correct. int x = 0; scanf("%d", x);

False

How many times the following while loop block executes? Assume complete code. int x= 1; While (x > 0) { printf("Defend the Empire \n"); printf("of the dark side\n"); printf("%d \n", x); x++; }

Indefinitely

A C function can return only one value.

True

A function may be called more than one time from a block of code

True

An array index is always an integer.

True

Code::Blocks is an IDE (Interactive Development Environment) in which you can write and edit your program

True

It is possible to assign a pointer to a C structure

True

It is possible to assign a pointer to an array

True

It is possible to convert a for loop to a while loop to get exactly the same result?

True

Programmer defined Structure is a data type

True

What does the condition of the following if statement evaluates to(true or false)? Given the followings: assume complete program. yes = 3; hi = 1; by = 2; yesterday = 1; today = 0; if (((yes <= hi) && ( hi = = by)) | | (yesterday != today))

True

You can pass as many arrays as you want to the same function at the same time.

True

what is the third general step in software development process. a. design b. test c. requirements d. maintenance e. implement

e

In C , you cannot have a pointer that points to another pointer.

false

You can have an "else" without an "if" in your program

false

What is the return type of rand( ) function?

int

What is the standard input device?

keyboard

Which one of the following shapes are used for input/output in flowcharts?

parallelogram

the expression, (iValue == iYourValue), compares the value of variable iValue to the value of variable iYourValue

true

If myarray is an array, then myarray[i] + 1 is the element in the array following myarray[i].

False

In C an (one array) array can have different data type as its elements

False

What is the base of binary numbers?

2

"The ____ character is used to dereference a pointer"

*

What value does this program prints out for the value of b if the user enters 2 for the value of d? #include <stdio.h> int main (void) { int a = 4, b, d, david = -5; printf("Enter a value for d:"); scanf("%d", &d); if ((a + d + david) <= 0) { b = david + d; printf("The value of b is %d\n", b); } else { b = david + a; printf("The value of b is %d\n", b); } return 0; }

-1

What is displayed after the following program executes? #include <stdio.h> int main(void) { int mar[3][3] = {{3,42,11},{12, 13, 14}, {55,32,66}}; int i,j; for (i=0; i<3; i++) { for (j=0;j<3;j++) { if((i + j) > 2) { printf("%d ", mar[i][j]); } } }

14 32 66

What is displayed by the following code? #include <stdio.h> int main(void) { int x = 6, y = 3, total = 9; do { x = y / 3; y = x * 2; total = x - y; } while (total != 0); printf ("%d", total); return 0; }

0

What are the values assigned the variables a, b, c, and d by the following code? Assume complete code. int a = 0, b= 1, c = 2, d = 3; while ( (b != 0 ) || (d !=3)) { if ( (c == 2) && (b > 1)) { b = b+d; a += 4; c = 5; } b = 0; }

0 0 2 3

How many times is a do while loop guaranteed to loop?

1

What is the value assigned to w in the line of code below. Assume all variables are declared. w = 6/4;

1

What is the final value of x when the code below executes. Assume complete code int x; for(x=0; x <= 10; x++) { some code.... }

11

What will be the output of the program? READ carefully #include <stdio.h> #include <math.h> double fun (double, double); int main (void) { double i = 2.0, x = 4.0; i = fun (i, x); printf("%f\n", i); return 0; } double fun(double i, double x) { double res = 0; res = pow (i , x); return ( res); }

16.0

Consider array numbers below , int numbers [5] = {3 , 5, 7, 9, 10}; What will be displays by the following code? Assume complete program. int counter =0; while ( numbers [counter] ! = 7) { printf( "%d " , numbers[counter]); counter += 1; }

3 5

What is the output of the following program? Be precise. #include <stdio.h> int main (void) { int i = 3, x = 7; double result = 1.0; while((x % i) != 0) { result = result * i; printf(" %.2f ", result); x = x + 1; i = i +1; } return 0; }

3.00

How many total double values can be stored in the following array? char lastname [8][20][2];

320

What is the following program's output? Hint: there is no \n in the printf statement. BE PRECISE. #include <stdio.h> int main(void) { int a=4; int b=3; int i; for (i=0; i< b; i++) { printf("%d", a -1); } return 0; }

333

What will be displayed by the following program? #include<stdio.h> struct numbers { int i; double ft; }; int main() { struct numbers decl; int i = 6; decl.i = 4; decl.ft = 7.96623; printf("%d %.2f", decl.i, decl.ft); return 0; }

4 7.97

Following set of code executes without any problems. Assume complete program. Line numbers are not part of the code. If no problem enter 0 as answer, if problem, enter the line number that has a problem as answer. 1.if ( temp > maxTemp) { printf ("turn air on \n"); } else ( temp <= maxTemp) { printf("do not touch the dial \n"); 8.}

5

Assume that pt1 is a pointer to integer x (x = 5) and pt2 is a pointer to integer y (y = 7). Assume complete code what will be displayed by the following code . pt1 = pt2; w = *pt1; printf( " %d", w);

7

After execution of the below loop, what value is assigned to variables total? Assume complete code. int total = 0, i = 7, y = 3 ; while (total < i) { total = total + y; y = y+2; }

8

How many bits are in a byte?

8

What is the value of variable x after the following code executes , assume complete code. int x = 5; int y = 3; x += y;

8

Assume complete code. int prossarray ( int [ ], int); int myarray[ ] = {1, 2 ,3 ,4, 5}; .......... some code .......... Which one of the following line of code passes the array to the function for processing? A. prossarray ( myarray, 5); B. prossarray ( &myarray [0], 5); C. both A and B D. None of the above

A

If the string is "Dark side of the Moon", using the function strlen returns : A. 21 B. 22 C. 17 D. it returns noting

A

What data type is used to represent number of apples in a box? A. integer B. Double C. Character D. None of the above

A

A prototype of a function looks like this: int myfunc (double x, int y, char d, int e); Which one of the following is a correct way to call this function? A. myfunc ( 1, 2, 3, 4); B. myfunc ( 1.1, 2, 'a', 2); C. myfunc ( 1, 'a', 2, 4.4); D. none of the above

B

A two dimensional array of characters has 4 columns and 7 rows. Which one of the following declaration is correct? A. char name[4] [7]; B. char name [7] [4]; C. char name [ ] [ ] ; D. none of the above

B

Machine code is in ________________________ numbering system

Binary

Assume the following code and complete program. Which one of the following assigns a pointer to structure variable Darth? struct person { char name[50]; int citNo; double salary; }; struct person Darth; A. struct person *ptst1 = Darth B. struct person *ptst1 = dart; C. strcut person ptsta1* = Darth; D. struct person *ptst1 = &Darth

D

Consider following structure, the correct syntax to access the member of the ith structure in the array of structures is: struct temp { int b; } tt [20] ; A. tt.b.[i]; B. tt.[i].b; C. tt.b[i]; D. tt[i].b;

D

Functions do not make your program A. Modularized B. Easier to maintain C. Easier to test D. More correct

D

Which of the following is a correct comment? Circle correct answer. A. */ Comments */ B. ** Comment ** C. */ Comment /* D. /* comment */

D

Which of the following is correct way to initialize an array in C. A. int john [3]; john [3] = {1,2,3}; B. int john [3] = {1,2,3}; C. int john [3] = (1,2,3); D. none of the above

D

Which one of the printf statements below is correct, considering the following partial code. Assume complete program. oranges = 10;weight = 1.2; totalWeight = oranges * weight; A- printf ("total weight of 10 oranges is 120 \n", oranges, totalWeight); B- printf ("total weight of %f oranges is %d \n", oranges, totalWeight); C- printf ("total weight of %d oranges is %d \n", oranges, totalWeight); D- None of the above

D

Which statement is correct regarding the following code? struct Student { char name[25]; int age; char branch[10]; //F for female and M for male char gender; }; struct Student S1, S2; //declaring variables of struct Student A. s1 and s2 are variable identifier (names) B. s1 and s2 are of structure data type C. s1 ans s2 can be used to access any members of struct student structure D. all the above

D

feof is a function that returns A. Checks for the end of a text file B. returns false if the end of the file is not reached C. it is not the only way to check for the end of the file D. all the above

D

ASCII character_____ designates the end of a text file"

EOF

"The dark side" is a string and "charray" is an array of characters. The following line of code is correct use of strcpy function. strcpy ("The dark side", charray);

False

A function must have arguments in order to process correctly.

False

A pointer variable can contain a double type number

False

A structure in C language can NOT have other structures as its members.

False

An array is saved in two different area of memory.

False

Assume complete code. The following code is correct. double area = 15.5; printf ( "area is %d ", area);

False

Assume complete program. char array1 [5] = "John"; char array2 [5] = "John"; The following condition of the if statement will evaluate to true or false? if (array1 == array2)

False

C is a interpreted programming language

False

Compilers convert the machine code into a source code

False

Consider the following array double thisarray [10]; Following line of code is correct and does not produce any error. Assume complete program. thisarray [10] = 3.3;

False

Following line of code declares a constant value for numbers of days in a year. #define NUM_DAYS_IN_YEAR = 365;

False

Following line of code declares a pointer called dVarp that point to a double variable called dVar. double *dVarp = dVar;

False

If a string is declared as in the declaration statement below, then a programmer would be able to store the string "David" in it with no unexpected problems. char str[5];

False

Which is not a loop structure? A. for B. do while C. repeat Until D. while

c

What will be the output of following program ? #include <stdio.h> void main(void) { int a=1; switch(a/2) { case 0: printf("Case ZERO\n"); break; case 1: printf("Case ONE\n"); break; case 2: printf("Case TWO\n"); break; default: printf("DEFAULT\n"); break; } }

compile error

Which one of the following is not a C operator a- % b- / c- ?: d- all are

d

What numbering system has 10 unique digits?

decimal


Related study sets

Domain II: Exercise Prescription and Implementation

View Set

Anatomy & Physiology: Chapters 6, 7, & 8

View Set

Module 35: Solving Problems and Making Decisions

View Set

Exploring Computer Science- state test reviews

View Set

Prep U Assessing Skin, Hair, and Nails

View Set

Skeletal System, Part 1, Calcium Homeostasis, Locklin

View Set

Genetics ...Patterns of Inheretence

View Set

Just One More Serving Please Lab

View Set