For this homework, you will hand in an English outline for your Programming Assi
ID: 3879622 • Letter: F
Question
For this homework, you will hand in an English outline for your Programming Assignment 1. This should be done in a C++ file. Name the file with your last name in this format (augustine-PA1-outline.cpp). You should use legitimate comments (// for single line or /* ...*/ for block comments). You should compile this on the Linux system (csegrid.ucdenver.edu) and get no syntax errors. You do NOT need to place other C++ code into the file. You can if you would like, but I would recommend putting those statements in comments, so that you spend most of your time putting the algorithm in plain English. Remember to put your name and information in comments at the top. Please do not just place all comments in a single set of block comments. The idea is to write a comment, and then a line or two of C++ code directly below that English Comment. Do what you can. Don't worry about perfection at this point. We want you to at least have a starting point....not the entire program complete....Good Luck. Please email me via email if you have questions.
For this programming assignment you will use cout, while loops, for loops, if statements (and for extra credit switch statements and reading in from a file)
Programming Assignment 1 Outline (10 points)
Create an outline in plain English using individual line comments. Make sure to indent. If something is associated with a loop for example you would say
//loop until …
//step 1
//step 2
Explanation / Answer
Answer:
code:
#include <iostream>
using namespace std;
int main()
{
// declare integer number and its reverse
int number, reverse ;
// initialize reverse to 0
reverse = 0;
//input the number from user suppose it is 456
cout<<"Enter an integer: ";
cin>>number;
cout<<"number= "<<number;
// while number is not reduced to 0, repeat the statements in the block
while(number!=0)
{
// calculate remainder 456%10=6
int remainder= number%10;
//reverse=6,reverse=6*10+5,reverse=65*10+4=654 ie reverse
reverse=reverse*10+remainder;
//number=45 ,number=4,number=0
number=number/10;
}
cout<<" Reversed number ="<<reverse;
return 0;
}
Output:
Please provide your valuable feedback.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.