0% found this document useful (0 votes)
116 views1 page

Mbeya University of Science and Tchnology GSB2205 Computer Programming II Cob 2202 Object Oriented Programming

This document contains instructions and questions for a Computer Programming II assignment on object oriented programming in C++. Students must: 1) Attempt all three questions. 2) Work in a group of five students. 3) Not copy other groups' work or their submission will be nullified. 4) Submit their group work by Monday, July 20th, 2020. The three questions involve: 1) Using if/else if to recognize character types entered through getchar(), 2) Using a for loop to compute sums and squares of natural numbers from 1 to 10, and 3) Writing a function to compute the volumes of cylinders based on dimensions entered and returning the results.

Uploaded by

Juanitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views1 page

Mbeya University of Science and Tchnology GSB2205 Computer Programming II Cob 2202 Object Oriented Programming

This document contains instructions and questions for a Computer Programming II assignment on object oriented programming in C++. Students must: 1) Attempt all three questions. 2) Work in a group of five students. 3) Not copy other groups' work or their submission will be nullified. 4) Submit their group work by Monday, July 20th, 2020. The three questions involve: 1) Using if/else if to recognize character types entered through getchar(), 2) Using a for loop to compute sums and squares of natural numbers from 1 to 10, and 3) Writing a function to compute the volumes of cylinders based on dimensions entered and returning the results.

Uploaded by

Juanitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

MBEYA UNIVERSITY OF SCIENCE AND TCHNOLOGY

GSB2205 Computer Programming II


Cob 2202 Object Oriented Programming

Instructions
1. Attempt ALL questions.
2. This assignment should be done in a group of five (5) students
3. Copy of other groups’ work shall be NULLIFIED.
4. Submit your group work on or before Monday 20th July, 2020

Question 1
Using an if else if staircase, write a C++ program that is capable receiving a
character entered through the keyboard using getchar() library function. Your
program should be able to recognize the type of a character entered as a digit, an
upper-case letter or lower-case letter or else print the message “Unrecognized
character”, if none of the mentioned character types is entered.
6 marks

Question 2
Using a for loop, write a C++ program that computes the sums and squares of the
natural numbers between 1 and 10 inclusive. That is, it computes the sum of 1 + 1,
then the square 1 * 1, 2 + 2, then 2 * 2, and so on. Let your output be in the
following format:
1+1= 2 2+2 = 4
1* 1 =1 2*2 = 4
….. …..
10 + 10 = 20 10 * 10 = 100 6 marks

Question 3
Write a C++ program to compute the volume of n number of cylinders. Let the main()
program prompt the user to enter the cylinder dimensions and pass these dimensions to a
function that perform computation of the cylinders volume one after the other, reach time
returning the result to main() that output the results of the cylinders volume in the following
format: The area of cylinder No. 1 is xx cubic meter.
The area of cylinder No. 2 is xx cubic meter.

The area of cylinder No. n is xx cubic meter.
Where xx is the volume computed.
(Note: The volume of a cylinder is given by v = r2h.
Qualify any standard constant used in your program) 8 marks

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy