The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 5 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
University of Sharjah
College of Sciences Department of Computer Science 1411113: Programming for
Engineers
Spring 2016 - 2017 Homework #4
Due Date: May 13th, 2017
Objectives: Basic practice on writing simple C++ programs. Basic practice on arrays and strings. Using Reference parameters. Exercise Out of 1
2 3
3 3 4 Mark Marking scheme
Assessment Item
Code correctness + modularity, etc.
Run-time errors/Wrong output Max. Mark
5
1.5 Naming of identifiers 1 Comments 1 Indentation 0.5 Output format 1 TOTAL 10 Integrity Statement: Read carefully!
Strict directives have been given to the assistants who will be marking this homework
to follow the University’s policy on cheating. Any student caught cheating in any
form will be given zero (0) the first time. (We will not get into the issue of who copied
from whom!!!). If such act reoccurs, the case will be sent to the University Student
Discipline Committee. Exercise #1: Word Count
1/2 Write a program that prompts the user to enter a sentence (not exceeding the size 100) and after
passing the sentence to a function, called wordCounter(), the function finds the number of words
and returns the word count back to the main() function for printing.
Sample Input/Output: Exercise #2: Mean and Standard Deviation
A company communicates with the world using Internet. The company wants data to be
transmitted securely in the form of 4-digit integers. Write a program for the company that
encrypts and decrypts their data by creating two functions, encrypt() and decrypt(). The user may
choose to encrypt or decrypt the integer based on his/her choice. Please note that the function
must not return anything but still the main() function will get the resulted number.
Encryption process will be as follows: Replace each digit of the integer input by (digit + 7) modulus
10; whereas the decrypted integer can be obtained by reversing the encryption process, i.e. (digit
+ 3) modulus 10.
Hint: You can use “pass by reference” method to get this effect.
Sample Input/Output: Exercise #3: Some operations on Strings
Write a program that passes an integer array of size 10 to a void function, called fillArray(), that
fills the array with random values (ranging from 1 to 100). The program then passes the filled array
along with a “random shifts” value (in the range of 0 to 10) to another void function, called
shiftArray(), that shifts the array elements to the right, based on the number of random shifts.
Hint: You can use the rand() and srand() predefined functions to get random numbers.
Sample output: 2/2
-----------