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
Write a C++ program named "PrintOneExpression" that will read in an expression and print out its formatted one with correct result. Objective: - make sure that you can have the C++ environment setup and can write programs with basic C++ input and output Requirements: - keep the expression simple with 2 operands and one operator(+,−,∗and/)- assume that the user will enter a correct expression. There is no need to handle errors in this exercise - all values in the expressions are integers - the output of the expression must be formatted with 5 spaces between each value and operator and must have the correct result of the expression.
Write appropriate C code for the following situation:
Write a simple C++ code as I am a beginner. The picture of the question is given below.  Create separate functions.
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
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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