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 (9th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Modern Database Management
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
- 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_forward#include #include #include #include using namespace std; int main (){ const double PI = 3.14159265359; return 0; }arrow_forwardC++ question i want the answer with little of explenationarrow_forward
- Slove in visual basicarrow_forwardC Programming What does the below code segment do? fprintf(stdout, “\nThis is my integer: %d”, &intMyInt);arrow_forward// LargeSmall.cpp - This program calculates the largest and smallest of three integer values. #include <iostream> using namespace std; int main() { // This is the work done in the housekeeping() function // Declare and initialize variables here int largest; // Largest of the three values int smallest; // Smallest of the three values // Prompt the user to enter 3 integer values // Write assignment, add conditional statements here as appropriate // This is the work done in the endOfJob() function // Output largest and smallest number. cout << "The largest value is " << largest << endl; cout << "The smallest value is " << smallest << endl; return 0; }arrow_forward
- T F The cout statement in the following program segment will display 5:int x = 5;cout << ++x;arrow_forwardB- Assume (n, d, m, f, k, e) are variables with integer data type in which n=1, d=m=f=2, e=9. Calculate the value of d, n, k and m for the following statement. Du d++ + --n+(k=e/2);arrow_forward/* Program Name: BadDate.cpp Function: This program determines if a date entered by the user is valid. Input: Interactive Output: Valid date is printed or user is alerted that an invalid date was entered */ #include <iostream> bool validateDate(int, int, int); using namespace std; int main() { // Declare variables int year; int month; int day; const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31; bool validDate = true; // This is the work of the housekeeping() method // Get the year, then the month, then the day // This is the work of the detailLoop() method // Check to be sure date is valid if(year <= MIN_YEAR) // invalid year validDate = false; else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month validDate = false; else if (day < MIN_DAY || day > MAX_DAY) // invalid day validDate = false; // This is the work of the endOfJob()…arrow_forward
- Consider the following code segment: of int numFeet, numInches; //number of feet // number of inches int totalInches -52; //total number of inches Write the statements to convert the total number of inches to feet and inches: a) Calculate the number of feet, and store the result in numFeet. b) Calculate the remaining number of inches, store the result in numinches.arrow_forward// LetterE.cpp - This program prints the letter E with 3 asterisks // across and 5 asterisks down. // Input: None // Output: Prints the outline of the letter E. #include <iostream> #include <string> using namespace std; int main() { const int NUM_ACROSS = 3; // Number of asterisks to print across const int NUM_DOWN = 5; // Number of asterisks to print down int row; // Loop control for row number int column; // Loop control for column number // This is the work done in the detailLoop() function // Write a loop to control the number of rows. // Write a loop to control the number of columns // Decide when to print an asterisk in every column. cout << "*"; // Decide when to print asterisk in column 1. cout << "*"; // Decide when to print a space instead of an asterisk. cout << " "; // Figure out where to place this statement that prints a newline.…arrow_forward// LetterE.cpp - This program prints the letter E with 3 asterisks // across and 5 asterisks down. // Input: None // Output: Prints the outline of the letter E. #include <iostream> #include <string> using namespace std; int main() { const int NUM_ACROSS = 3; // Number of asterisks to print across const int NUM_DOWN = 5; // Number of asterisks to print down int row; // Loop control for row number int column; // Loop control for column number // This is the work done in the detailLoop() function // Write a loop to control the number of rows. // Write a loop to control the number of columns // Decide when to print an asterisk in every column. cout << "*"; // Decide when to print asterisk in column 1. cout << "*"; // Decide when to print a space instead of an asterisk. cout << " "; // Figure out where to place this statement that prints a newline.…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