0% found this document useful (0 votes)
102 views

HW3 - Programming For Eng

This document contains instructions for Assignment #3 of the Programming for Engineers course. It provides two programming problems to solve related to generating random numbers and checking for perfect and palindrome numbers. It specifies that the source code must be named according to the question number, student ID and section. It also warns that similar code submissions will receive a zero grade. The document provides sample input/output for each problem to help guide the development of the programs.

Uploaded by

nblzhr01
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

HW3 - Programming For Eng

This document contains instructions for Assignment #3 of the Programming for Engineers course. It provides two programming problems to solve related to generating random numbers and checking for perfect and palindrome numbers. It specifies that the source code must be named according to the question number, student ID and section. It also warns that similar code submissions will receive a zero grade. The document provides sample input/output for each problem to help guide the development of the programs.

Uploaded by

nblzhr01
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1411113 Programming for Engineers

Assignment #3
Due Date: 29
th
April 2014
Submission Instructions:
Submit your assignment on the blackboard link, corresponding to your Section:
Please follow the following rules when sending the source code:
1) The name of the file should be q#_myID_section.cpp (for e.g: q1_u000002046_51.cpp)
2) In case two assignments are found to be similar, both students will get ZERO.
Chapter # 6:
1. The Write a program that:
a. Prompts the user to enter a positive integer N.
b. Generates N integers between 7 and 19 inclusive.
c. Prints the integers, the number of odds, and the number of evens.
d. Counts how many odd and how many even integers generated.
Sample input / output:

2. The Write a program that:
a. Prompts the user to enter a positive integer N.
b. Calls the user-defined function isPerfect( ) which checks if N is perfect or not. A
number is perfect if the sum of its divisors other than the number itself. For
example 28 is perfect since 28 = 1 + 2 + 4 + 7 + 14, while 8 is not perfect since 8
1+ 2 + 4
c. Prints a message.
Sample input / output:



Chapter # 7:
3. Write a function (and the main method to test it) that prompts the user to input the
total distance in centimeters. The function then returns the distance in kilometers,
meters, and centimeters.
void distanceKMC(int totalDist, int & km, int & m, int & cm)

4. Write the following program:
A. Write a value-returning function called length() that takes a positive integer and
returns the number of digits in that integer.
B. Using the written function in part A, write a value-returning function called
isPalindrome() that checks if a positive integer is a palindrome or not. A number is
palindrome if it reads the same left to right and right to left. For example 23432 is a
palindrome, while 5675 is not palindrome. The function takes a positive integer and
returns true if the integer is a palindrome and false otherwise.
Test your functions by writing a main function that prompts the user to input an integer
and outputs its number of digits and "It Is a Palindrome" message if it is a palindrome,
otherwise "It Is not a Palindrome".

You might also like