1 Replies - 970 Views - Last Post: 03 May 2010 - 06:18 PM Rate Topic: -----

#1 Guest_jesee*


Reputation:

Can anyone help me with these questions.

Posted 03 May 2010 - 06:05 PM

I need help with three questions that will appear on my final exam. You don't have to do them for me, but if you give me an general idea of how to do them I would appreciate it.

1. Write a boolean function bool valid(int grade) which returns true if the grade is btween 20 and 90 inclusive.

2. Write a function void print_even(int x[], int num_values) which prints the even numbers in the array, and how many there are.

3. Write a function void print_around(char M[9][9], int row, int col) which prints the elements to the left, to the right, directly above and directly below M[row][col].

Is This A Good Question/Topic? 0

Replies To: Can anyone help me with these questions.

#2 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3207
  • View blog
  • Posts: 19,239
  • Joined: 14-September 07

Re: Can anyone help me with these questions.

Posted 03 May 2010 - 06:18 PM

The problem is, there really isn't a way to provide guidance for these question without doing the assignment. Having that said, I'll attempt to do so.


1. Do a conditional check (you'll need two), return the result.

2. Iterate through the array, checking it's even/odd state (hint: use the modulo operator). Keep a counter incrementing each time you find one.

3. You're given a specific index: [row][col]. So you'll need to print the "square" around that index. +/- one in any direction. The kicker is that you'll need to check to see if the indexes are valid (i.e. out of bounds if it's in a "corner")




Provide your attempts and we'll be happy to help you out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1