C By Discovery (4th Edition)

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 1320 – Section 001 Midterm 1 (Practice A) Name:_____________________________________________________Grade: ___________ [100pts] 1. Predict the output of the program below that uses arithmetic operators and precedence. Write the output in the spaces below. Write one character per space. Indicate end of lines with the symbol ‘\n’. [10pts] int a, x, y; __________3_\n___________ x = y = 2 * 3/4; __________0_\n___________ printf(“%d\n”, 3*x+ y/2); _________________________ a = 2 * 5 % 2 + x; _________________________ printf(“%d\n”, a * 2 / 3); _________________________ 2. Write a function multiple(int x, int n) to test if the integer x is a multiple of the integer n. The function should return 1 if x is a multiple of n. Otherwise, the function returns 0. Your code should contain the heading, declarations, blocks, and statements necessary. [10pts] multiple(int x, int n) { int multFlag; multFlag = (x % n) == 0; return multFlag; } 3. Implement a function average(int array[], int n) that computes the average of n integer values in an array of integers. Your function should take the array and the number of elements in the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

Practice1A - CSE 1320 Section 001 Midterm 1 (Practice A)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online