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
I need to resolve the following....You are trying to convince your boss that your company needs to invest in a license for MS-Project (project management software from Microsoft) before beginning a systems project. What arguments would you give her?
What are the four types of feasibility? what is the issues addressed by each feasibility component.
I would like to get ab example of a situation where Agile Methods might be preferable versus the traditional SDLC? What are the characteristics of this situation that give Agile Methods an advantage?
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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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