Programming and Problem Solving With C++
Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 4, Problem 1PSCS
Program Plan Intro

Program Plan:

To input the user's name and the Social Security Number and print the details in different formats.

Expert Solution & Answer
Check Mark

Explanation of Solution

Program:

#include <iostream>
usingnamespace std;
intmain()
{
stringfname, lname; // string declared for the first name and the last name
intssn; // integer declared for the Social Security Number
cout<<"Enter your first name:\n";
cin>>fname;
cout<<"Enter your last name:\n";
cin>>lname;
cout<<"Enter your Social Security Number:\n";
cin>>ssn;
cout<<"Your details are:\n";
// details will be printed in different formats.
cout<<ssn<<", "<<fname<<", "<<lname<<endl;
cout<<ssn<<", "<<lname<<", "<<fname<<endl;
cout<<lname<<", "<<fname<<", "<<ssn<<endl;
return 0;
}

Explanation:

An 'iostream' is a header file or a pre-defined file in which cin and cout is defined.

To use the header files in the program, keyword include is written before the header file name surrounded with angular brackets.

The include keyword is always written after the '#', which is known as a preprocessor.

A preprocessor means something is being processed before the program. A preprocessor shows that the header files are processed before the program.

A 'using' is a keyword used to specify namespace or file is used with the program.

A ' namespace' is typically a container for a collection of identifiers. A namespace provides a degree of context for different identifiers, making it possible to differentiate identifiers with the same name.

C++ transferred all the standard library's features to a namespace called "std" (standard).

The cout is the keyword used to print a message or a value to the user or on the screen.

The cin keyword takes input from the user.

A main is the default name given to the main function of a program where the return type means function should return some value, here return type int is given.

In a program, the return type of the main function is int, that is, it should return an integer value. The return is considered as the exit status of an application.

Sample Output:

  Programming and Problem Solving With C++, Chapter 4, Problem 1PSCS

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
in C++ please For this problem you must create a program that accepts a line of English text as input. The string may contain spaces, so make sure you read the entire line of input. Next your program should count the occurrences of each letter of the English alphabet and determine which letter occurs most frequently in the string. Print this letter to the screen. If two letters tie for the most frequent count, break the tie by choosing the letter that occurs first in the alphabet. For example if the input string was "aabb", then your program should identify 'a' as the most frequently occurring letter. Finally, remove all occurrences of this most frequently occurring letter by replacing them with the '-' character, and print the final string to the screen. Sample Input aaaab Sample Output a ----b Simplifying Assumptions You may assume that all letters are lowercase You only need to count the letters of the alphabet (i.e. don't worry about counting special characters like punctuation,…
Create a C++ student enrollment system using classes and objects. The program should ask the student for their details (name, gender, address), choose from the list which course they want to take, display their tuition fee, and ask them if they want to apply for a scholarship (if yes, it displays scholarship choices, if no, the program ends). code can only include the basic input and output, the different if statements, switch statement, void function, loop, and of course, classes and objects. please include pseudocodes in every line with detailed explanation. also, please just screenshot the code so it'd be easier to read. thank you.
In C++ For this problem you must create a program that accepts a line of English text as input. The string may contain spaces, so make sure you read the entire line of input. Next your program should count the occurrences of each letter of the English alphabet and determine which letter occurs most frequently in the string. Print this letter to the screen. If two letters tie for the most frequent count, break the tie by choosing the letter that occurs first in the alphabet. For example if the input string was "aabb", then your program should identify 'a' as the most frequently occurring letter. Finally, remove all occurrences of this most frequently occurring letter by replacing them with the '-' character, and print the final string to the screen. HINT: Since ascii characters are stored as 8 bit ints "under the hood", and they are also represented in order (i.e. 'a' comes before 'b'); we can use them both as characters as well as for counting. Thus if we wanted to loop through all of…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
What is Abstract Data Types(ADT) in Data Structures ? | with Example; Author: Simple Snippets;https://www.youtube.com/watch?v=n0e27Cpc88E;License: Standard YouTube License, CC-BY