#include using namespace std; int main() { int trm, bs, r, q, i, num; cout << "\n\n Print the first N numbers for a specific base:\n"; cout << " The number 11 in base 10 = 1*(10^1)+1*(10^0)=11" << endl; cout << " Similarly the number 11 in base 7 = 1*(7^1)+1*(7^0)=8" << endl; cout << "----------------------------------------------------------------\n"; cout << " Input the number of term: "; cin >> trm; cout << " Input the base: "; cin >> bs; cout << " The numbers in base " << bs << " are: " << endl; for (i = 1; i <= trm; i++) { r = i % bs; q = i / bs; num = q * 10 + r; cout << num << " "; } cout << endl; } Do this by while loop
#include using namespace std; int main() { int trm, bs, r, q, i, num; cout << "\n\n Print the first N numbers for a specific base:\n"; cout << " The number 11 in base 10 = 1*(10^1)+1*(10^0)=11" << endl; cout << " Similarly the number 11 in base 7 = 1*(7^1)+1*(7^0)=8" << endl; cout << "----------------------------------------------------------------\n"; cout << " Input the number of term: "; cin >> trm; cout << " Input the base: "; cin >> bs; cout << " The numbers in base " << bs << " are: " << endl; for (i = 1; i <= trm; i++) { r = i % bs; q = i / bs; num = q * 10 + r; cout << num << " "; } cout << endl; } Do this by while loop
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter2: Basic Elements Of C++
Section: Chapter Questions
Problem 33SA
Related questions
Question
#include <iostream> using namespace std; int main() { int trm, bs, r, q, i, num; cout << "\n\n Print the first N numbers for a specific base:\n"; cout << " The number 11 in base 10 = 1*(10^1)+1*(10^0)=11" << endl; cout << " Similarly the number 11 in base 7 = 1*(7^1)+1*(7^0)=8" << endl; cout << "----------------------------------------------------------------\n"; cout << " Input the number of term: "; cin >> trm; cout << " Input the base: "; cin >> bs; cout << " The numbers in base " << bs << " are: " << endl; for (i = 1; i <= trm; i++) { r = i % bs; q = i / bs; num = q * 10 + r; cout << num << " "; } cout << endl; }
Do this by while loop
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr