Concept explainers
What will the following
cin statement asks the user to input a letter?
char letter ;
cout << "The ASCII values of uppercase letters are "
<< static_cast<int>('A')<< "-"
<< static_cast<int>('Z')<< endl;
cout <<"The ASCII values of lowercase letters are "
<< static_cast<int>('a') << "-"
<< static_cast<int>('z') << endl << endl;
cout << "Enter a letter and I will tell you its ASCII code: ";
cin >> letter;
cout << "The ASCII code for " << letter << " is "
<< static_cast< int>(letter) << endl;
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
C++ How to Program (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Programming Logic and Design (4th Edition)
- C programringarrow_forwardA program contains the following function. int cube(int num) {return num * num * num; }Write a statement that passes the value 4 to this function and assigns its return value to the variable result.arrow_forwardB- Declare a constant of character type with initial value='G' o Const char LETTER ='G'; O #define LETTER 'G'arrow_forward
- Test Average and Grade - MUST BE WRITTEN IN PSEUDOCODEarrow_forwardThe Problem__: Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: ⚫ void getScore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the five scores to be entered. ⚫ void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. ⚫int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100. YOU MUST USE THE STATED FUNCTIONS AND COMPLETE Input VALIDATION. **DO NOT use an ARRAY OR GLOBAL VARIABLES!!. you MUST USE function prototyping TEST THE FUNCTION TWICE.…arrow_forwardNone [] # Don't write code in this line Q5: Complete the function that calculates the position of an object at any time t> 0. The initial position and the initial velocity (at time t=0) are denoted as so and v0 respectively. The object undergoes constant acceleration a, for any time t>0. [ ]: def calculate_position (s0,u,a,t): "given the initial conditions and acceleration, return the object's position. Use the variable named 'position' to hold and return this value """ # YOUR CODE HERE return position I ↑↓古早 Check your code here " Assign random input variables and check the answer"arrow_forward
- c++ languagearrow_forwardc code Screenshot and output is mustarrow_forwardComputer Science I need to write a program in C that allows the user to play a game of Mystery Word, here are the requirements: The program begins with a 6-letter word which is obscured by displaying an asterisk * in the place of each letter of the word. Four 6-letter words should be included in your program and have a theme. The word should be randomly selected when the user begins the game. After 7 incorrect guesses the user loses the game. The player wins by correctly guessing all of the letters that are part of the word. At each step, the program should remind the player of the letters he or she has already guessed, the program should not be case sensitive for input, but keep the output as uppercase letters. If the user enters the same letter twice that should count against them. Any help would be greatly appreciated as I'm stumped on how to complete this one.arrow_forward
- The program segment has errors. Find as many as you can. // This code should display the sum of two numbers. int choice, num1, num2; do {cout << "Enter a number: "; cin >> num1;cout << "Enter another number: "; cin >> num2;cout << "Their sum is " << (num1 + num2) << endl;cout << "Do you want to do this again?\n";cout << "1 = yes, 0 = no\n"; cin >> choice;} while (choice = 1)arrow_forwardFunction strlen() takes a string as an argument and returns the number of characters in the string, Which of the following is the correct answer to fill the above statement with it? Select one: a. Spaces are not included in the length calculation b. Null character is not included in the length calculation c. Numbers are not included in the length calculation d. Null character is included in the length calculationarrow_forwardC++ Programming Instructions Write a program that prompts the user for a sequence of characters (all typed on a single line) and counts the number of vowels ('a', 'e', 'i', 'o', 'u'), consonants, and any other characters that appear in the input. The user terminates input by typing either the period (.) or exclamation mark character (!) followed by the Enter key on your keyboard. Your program will not count white space characters.I.e., you will ignore white space characters.Though, the cin statement will skip white space characters in the input for you. Your program will not be case-sensitive. Thus, the characters 'a' and 'A' are both vowels and the characters 'b' and 'B' are both consonants. For example, the input How? 1, 2, 3. contains one vowel, two consonants, and six other kinds of characters. IMPORTANT: Your program must use the while statement only when looping. I.e., do not use a for statement or any other looping statement. Test 1 > run Enter text: . Your sentence has 0…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage