STARTING OUT C++.+MATLAB+MYPROGRAMLABCD
STARTING OUT C++.+MATLAB+MYPROGRAMLABCD
18th Edition
ISBN: 9781323886083
Author: GADDIS/MOORE
Publisher: PEARSON C
Expert Solution & Answer
Book Icon
Chapter 11, Problem 1RQE

Explanation of Solution

Primitive data type:

Primitive data types are pre-defined data types, which can be used directly by the programmers to declare the variables.

Some of the primitive data types available in C++ programming language are as follows:

Integer:

  • Integer is one of the predefined data types. The keyword used for declaring integer data type is “int”.
  • It takes up to 4 bytes of memory space to store data. It ranges from -147483648 to 2147483647.
  • Example for declaring integer data type is as follows:
    • int variable1 = 10;

Floating point:

  • Floating point is a predefined data type. The keyword used for declaring floating point is “float”.
  • It takes up to 4 bytes of memory space to store data. It ranges from +/- 3.4e +/- 38.
  • Example for declaring floating point data type is as follows:
    • float variable1 = 10.3;

Character:

  • Character is a predefined data type. The keyword used for declaring character data type is “char”.
  • It takes 1 byte of memory space to store data. It ranges from -127 to 127 or 0 to 255
  • Example for declaring character data type is as follows:
    • char variable1 = 'a';

Boolean:

  • Boolean is a predefined data type. The keyword used for declaring Boolean data type is “bool”. It stores data in the form of “true” or “false”.
  • Example for declaring Boolean data type is as follows:
    • bool variable1 = true;

Double Floating point:

  • Double Floating point is a predefined data type. The keyword used for declaring double is “double”.
  • It takes up to 8 bytes of memory space to store data. It ranges from +/- 1.7e +/- 308
  • Example for declaring double data type is as follows:
    • double variable1 = 11.34;

Void:

  • Void represents null value. The keyword used for void is “void”.

Wide Character:

  • Wide Character is a predefined data type. The keyword used for declaring  wide character is “wchar_t”.

Example:

The below program demonstrates the usage of primitive data type “integer”:

//Include the header files

#include<iostream>

using namespace std;

//Main function

int main()

{

//Variable declaration

int i, n = 5;

//for loop to print 1 to 5

for (i = 1; i <= n; i++)

{

//print the value of “i”

cout << i << "\n";

}

//Print a new line

cout << "\n";

//Return the value 0

return 0;

}

Expert Solution & Answer
Check Mark
Sample Output

1

2

3

4

5

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 integer data types ?
What Is A primitive types?
What is a dangling pointer?

Chapter 11 Solutions

STARTING OUT C++.+MATLAB+MYPROGRAMLABCD

Ch. 11.10 - Prob. 11.11CPCh. 11.10 - Write a function that uses a Rectangle structure...Ch. 11.10 - Prob. 11.13CPCh. 11.10 - Prob. 11.14CPCh. 11.10 - Prob. 11.15CPCh. 11.11 - Look at the following declaration: enum Flower {...Ch. 11.11 - What will the following code display? enum {...Ch. 11.11 - Prob. 11.18CPCh. 11.11 - What will the following code display? enum Letters...Ch. 11.11 - Prob. 11.20CPCh. 11.11 - Prob. 11.21CPCh. 11 - Prob. 1RQECh. 11 - Prob. 2RQECh. 11 - Prob. 3RQECh. 11 - Look at the following structure declaration:...Ch. 11 - Look at the following structure declaration:...Ch. 11 - Look at the following code: struct PartData {...Ch. 11 - Look at the following code: struct Town { string...Ch. 11 - Look at the following code: structure Rectangle {...Ch. 11 - Prob. 9RQECh. 11 - Look at the following declaration: enum Person {...Ch. 11 - Prob. 11RQECh. 11 - The ______ is the name of the structure type.Ch. 11 - The variables declared inside a structure...Ch. 11 - A(n) ________ is required after the closing brace...Ch. 11 - In the definition of a structure variable, the...Ch. 11 - Prob. 16RQECh. 11 - Prob. 17RQECh. 11 - Prob. 18RQECh. 11 - Prob. 19RQECh. 11 - Prob. 20RQECh. 11 - Declare a structure named TempScale, with the...Ch. 11 - Write statements that will store the following...Ch. 11 - Write a function called showReading. It should...Ch. 11 - Write a function called findReading. It should use...Ch. 11 - Write a function called getReading, which returns...Ch. 11 - Prob. 26RQECh. 11 - Prob. 27RQECh. 11 - Look at the following statement: enum Color { RED,...Ch. 11 - A per store sells dogs, cats, birds, and hamsters....Ch. 11 - T F A semicolon is required after the closing...Ch. 11 - T F A structure declaration does not define a...Ch. 11 - T F The contents of a structure variable can be...Ch. 11 - T F Structure variables may not be initialized.Ch. 11 - Prob. 34RQECh. 11 - Prob. 35RQECh. 11 - T F The following expression refers to element 5...Ch. 11 - T F An array of structures may be initialized.Ch. 11 - Prob. 38RQECh. 11 - T F A structure member variable may be passed to a...Ch. 11 - T F An entire structure may not be passed to a...Ch. 11 - T F A function may return a structure.Ch. 11 - T F when a function returns a structure, it is...Ch. 11 - T F The indirection operator has higher precedence...Ch. 11 - Prob. 44RQECh. 11 - Find the Errors Each of the following...Ch. 11 - Prob. 46RQECh. 11 - struct TwoVals { int a, b; }; int main () {...Ch. 11 - #include iostream using namespace std; struct...Ch. 11 - #include iostream #include string using namespace...Ch. 11 - struct FourVals { int a, b, c, d; }; int main () {...Ch. 11 - Prob. 51RQECh. 11 - struct ThreeVals { int a, b, c; }; int main () {...Ch. 11 - Prob. 1PCCh. 11 - Movie Profit Modify the program written for...Ch. 11 - Prob. 3PCCh. 11 - Weather Statistics Write a program that uses a...Ch. 11 - Weather Statistics Modification Modify the program...Ch. 11 - Soccer Scores Write a program that stores the...Ch. 11 - Customer Accounts Write a program that uses a...Ch. 11 - Search Function for Customer Accounts Program Add...Ch. 11 - Speakers Bureau Write a program that keeps track...Ch. 11 - Prob. 10PCCh. 11 - Prob. 11PCCh. 11 - Course Grade Write a program that uses a structure...Ch. 11 - Drink Machine Simulator Write a program that...Ch. 11 - Inventory Bins Write a program that simulates...
Knowledge Booster
Background pattern image
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