Hello everyone, I currently have an assignment where I'm supposed to enter a character, and then a number, and in accordance it prints out the corresponding value.
For example:
Enter a character:
input: a
Enter a number:
input: 5
output: abcdef
The above is the correct output. My program however, prints out what a5 would be on the table, so a little help! I'll include the sample program the professor provided as well. Thank you!
//Lab 19
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int i1, answer;
char c;
cout << "Enter a character: ";
cin >> c;
for (int i = 1; i < 999; i++){
cout << "\nEnter a number: ";
cin >> i1;
if (i1 <= 260){
break;
}
}
for (int i = 1; i <= i1; i++){
c = i1;
cout << c;
}
cout << endl;
cout << "Run it back?";
cin >> answer;
if (answer == 'y' || answer == 'Y'){
main();
}
else if (answer == 'n' || answer == 'N'){
system("PAUSE");
return 0;
}
}
Question
coolbunny1234
Hello everyone, I currently have an assignment where I'm supposed to enter a character, and then a number, and in accordance it prints out the corresponding value.
For example:
Enter a character:
input: a
Enter a number:
input: 5
output: abcdef
The above is the correct output. My program however, prints out what a5 would be on the table, so a little help! I'll include the sample program the professor provided as well. Thank you!
Example program: https://www.dropbox.com/s/o7qfirh0imou5ub/C%2B%2BLab19%20%28ASCII_Characters%29.exe
Link to comment
Share on other sites
2 answers to this question
Recommended Posts