首页 > > 详细

C++辅导计算一个100-999的三位数 CMPSC 101讲解C/C++

Introduction
Requirement
CMPSC 101 Due: January 30, 2017
Spring 2017
Problem Set 2
Each program source file must have, at the beginning of the program, a “banner comment” of the following form.:
//———————————————————-
// Name:
// E-mail Address:
// Class: CMPSC 101
// Project #
// Due Date:
// Brief Project Description
//———————————————————-
Your programs should include appropriate comments and should follow the program documentation requirements listed in the syllabus.
(15 points) Write a program that prompts the user to enter an integer number between 0 and 1000 and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14.
Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932%10 is 2 and 932/10 is 93.
Here is a sample run:
Enter an integer number between 0 and 1000: 999
The sum of the digits is 27.
Submission Instruction:
• Submit your source file via Angel by the beginning of the class on January 30, 2017.
• Hardcopy submission is due at the beginning of the class on January 30, 2017.
• You only need to submit your source code file (.cpp).
• See the course syllabus for more detailed information on how to submit your work.

 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!