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++
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;
}
1
2
3
4
5
Want to see more full solutions like this?
Chapter 11 Solutions
Starting Out with C++ from Control Structures to Objects, Student Value Edition (9th Edition)
- Find the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(6): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': '))arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it and normalize it? Give two references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Consider that the database offline is not allowed since people are connected to it and personal data might be bridged and not secured. Provide three refernces with you answer.arrow_forward
- Should software manufacturers should be tolerant of the practice of software piracy in third-world countries to allow these countries an opportunity to move more quickly into the information age? Why or why not?arrow_forwardI would like to know about the features of Advanced Threat Protection (ATP), AMD-V, and domain name space (DNS).arrow_forwardPlease show the code for the Tikz figurearrow_forward
- Modern life has been impacted immensely by computers. Computers have penetrated every aspect of oursociety, either for better or for worse. From supermarket scanners calculating our shopping transactionswhile keeping store inventory; robots that handle highly specialized tasks or even simple human tasks,computers do much more than just computing. But where did all this technology come from and whereis it heading? Does the future look promising or should we worry about computers taking over theworld? Or are they just a necessary evil? Provide three references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forwardYou are called by your supervisor to go and check a potential data bridge problem. What are the stepsyou will follow in order to check the database and fix any problems with it? Have in mind that youSHOULD normalize it as well. Describe in full, consider the following:• Taking the database offline is not allowed since people are connected to it.• Personal data might be bridged and not secured. Provide three refernces with you answerarrow_forward
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage