c++ Code... most basic c++ code you could come up with Characters for the ASCII
ID: 3849359 • Letter: C
Question
c++ Code... most basic c++ code you could come up with
Characters for the ASCII Codes
Write a program that uses a loop to display the characters for each ASCII code 32 through 127.Display 16 characters on each line with a space between one character and the next one.
Set up a function that receives a short integer (short int) and returns the corresponding ASCIIcharacter. The function must work returning an ASCII character regardless of the received value.HINT: ASCII codes go from 0 to 127.
*keep it as simple as possible*
*use two nested loops*
Explanation / Answer
#include <iostream>
using namespace std;
char getASCII( short input ){
return (char)(input);
}
int main(){
for(int i = 32; i <= 127; i+=16){
for(int j= i; j<i + 16 ; j++){
cout << getASCII(j) << " ";
}
cout << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.