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
What are the major threats of using the internet? How do you use it? How do children use it? How canwe secure it? Provide four references with your answer. Two of the refernces can be from an article and the other two from websites.
Assume that a string of name & surname is saved in S. The alphabetical characters in S can be in lowercase and/or uppercase letters. Name and surname are assumed to be separated by a space character and the string ends with a full stop "." character. Write an assembly language program that will copy the name to NAME in lowercase and the surname to SNAME in uppercase letters. Assume that name and/or surname cannot exceed 20 characters. The program should be general and work with every possible string with name & surname. However, you can consider the data segment definition given below in your program. .DATA S DB 'Mahmoud Obaid." NAME DB 20 DUP(?) SNAME DB 20 DUP(?) Hint: Uppercase characters are ordered between 'A' (41H) and 'Z' (5AH) and lowercase characters are ordered between 'a' (61H) and 'z' (7AH) in the in the ASCII Code table. For lowercase letters, bit 5 (d5) of the ASCII code is 1 where for uppercase letters it is 0. For example, Letter 'h' Binary ASCII 01101000 68H 'H'…
What did you find most interesting or surprising about the scientist Lavoiser?
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