Question

I C++ write a program where the program picks a character . Then program then prints...

I C++ write a program where the program picks a character . Then program then prints the character and its ASCII integer value.

Homework Answers

Answer #1
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
   char ch;
   int ascii;
   
   srand(time(0)); 
   
   ch = (char)(rand()%256);
   
   ascii = (int)ch;
   
   cout<<"Ascii integer value for character '"<<ch<<"' is "<<ascii<<endl;
   return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
problem 1 Write a program that asks the user for an integer and then prints out...
problem 1 Write a program that asks the user for an integer and then prints out all its factors. For example, when the user enters 84, the program should print 2 2 3 7 Validate the input to make sure that it is not a character or a string using do loop. in c plus plus
C++ Write a program which accepts a character from the user. If the character is between...
C++ Write a program which accepts a character from the user. If the character is between 0 and 9, it will output that it's a digit. If the character is lowercase it will output that its a lowercase character. If it's an uppercase character it will output that it's uppercase. For all other cases it will output that it's neither a digit nor a letter. As an example of the output: Enter a digit or a letter: A You entered...
In Python only. Write a program that prompts the user to enter a hex character and...
In Python only. Write a program that prompts the user to enter a hex character and displays its corresponding decimal integer.
I need know how to Write a java program called character length that prompts the user...
I need know how to Write a java program called character length that prompts the user to enter a string and displays:x is the first character.) The length of the string is: xxxxx The strings first character is: x (where xxxxx is the length of the string and x is the first character.)
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all...
Write a program in JAVA that prints the bounds ( maximum and minimum values) for all integer data types in Java.
This is the program that I need to make. Write a program that prints three items,...
This is the program that I need to make. Write a program that prints three items, such as the names of your three best friends or favorite movies, on three separate lines. This is what I did. #include <iostream> using namespace std; int main() { cout << "Suresh" << endl; cout << "Sekhar" << endl; cout << "Anshu" << endl; return 0; } Then it tells me that the program fails to test the submission with three random names. Please...
Please use basic Java program and comment so that I understand what is going on.   write...
Please use basic Java program and comment so that I understand what is going on.   write a class called lab1. (This will be your program.) In that class: Write the main method that calls multiConcat. Write a method called multiConcat that takes a String and an integer as parameters and prints a String that is the parameter string concatenated with itself n number of times (where n is the second parameter). For example, if the parameters are “hi” and 4,...
write a python program for a function that takes in an integer n and prints the...
write a python program for a function that takes in an integer n and prints the nth taylor approximation for the function f(x)=e^x at the point x=0 to x=1
Write a program in C that uses recursion to calculate and print the factorial of the...
Write a program in C that uses recursion to calculate and print the factorial of the positive integer value passed in or prints the line "Huh?" if no argument is passed or if the first argument passed is not a positive integer. If the value passed in exceeds 10, you can simply print "Overvalue".
C program- using visual studio code. Write a program that asks for an integer and then...
C program- using visual studio code. Write a program that asks for an integer and then prints all the alternative integers from (and including) that value up to (and including) a value larger by 20. (That is, if the input is 5, the output runs from 5 to 25.) Be sure to separate each output value by a space or tab