Question

C++ Language 1. List any four different data types that have been discussed in class and/or...

C++ Language

1. List any four different data types that have been discussed in class and/or used in your programs.

2. The expression 4 + 6 / 3 * 0 evaluates to

3. Code two different ways to add 1 to a variable called count and have the result stored in count.

Homework Answers

Answer #1

1.The four data types used in c++ are:

  • Integer : It is used by the keyword int . It is used to store integer values such as (1,2,3) etc. The size is generally 4bytes.
  • Character: It is used by the keyword char. It is used for representing a single character. Like 'a','b' etc.The size is generally 1byte.
  • Boolean: It is used by the keyword bool and it is used for representing true or false values. It is mainly used for logical equivalence.
  • Floating Point: It is used by the keyword float and used by representing single precision floating number/point. The size is of 4bytes.

2. The output of the code is 4 because it uses the simple BODMAS rule to calculate the expression.

  • So first 6/3 which will give 2.
  • 2*0=0
  • 4 + 0 =4

So the answer is 4.

3.The two different ways are as follows:

  • First way:
    • #include <bits/stdc++.h>
      
      using namespace std;
      
      int main(){
          // First way
          int count = 0;
          count = count  + 1;
          return 0;
      }
  • Second way:
    • #include <bits/stdc++.h>
      
      using namespace std;
      
      int main(){
          // Second way
          int count = 0;
          count = count++;
          return 0;
      }

I have included the necessary comments that will help you understand the solution.

I hope you have understood the solution. If you like the solution kindly upvote it.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(),...
The language is Java. Using a singly-linked list, implement the four queue methods enqueue(), dequeue(), peek(), and isEmpty(). For this assignment, enqueue() will be implemented in an unusual manner. That is, in the version of enqueue() we will use, if the element being processed is already in the queue then the element will not be enqueued and the equivalent element already in the queue will be placed at the end of the queue. Additionally, you must implement a circular queue....
all are True or False 1 An inner class may access private data of the containing...
all are True or False 1 An inner class may access private data of the containing class, 2 An inner class has a special constructor that has different characteristics of a 'normal' class. 3 An inner class that has no name and is both declared and created at the same time is called an unnamed class. 4 The purpose of closures (lambda expressions) is to make the code more readable to others who may need to maintain and support it....
** Language Used : Python ** PART 2 : Create a list of unique words This...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code from a prior assignment ). Each list should be able to store 100 names. Part 2 - Create a Class ArrayListClass It will contain an array of 27 "list" classes. Next, create a Class in which is composed a array of 27 list classes. Ignore index 0... Indexes 1...26 correspond to the first letter of a Last name. Again - ignore index 0. index...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
Design a class with the following requirements: 1- give the class a name from your choice....
Design a class with the following requirements: 1- give the class a name from your choice. 2- write some code that creates three instance variables, choose a name and type for each one of them. (must have two private and one public variables) 3- Initialize the variables using two different constructors. 4- Use mutator and accessor methods (set and get) for the private data members. 5- Display the value of each member variable using a method. 6- In the main,...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Choose any 5 types of cultural diets from the following list : 1. Jewish 2. Hispanic...
Choose any 5 types of cultural diets from the following list : 1. Jewish 2. Hispanic 3. Asian (Korean, Chinese, Japanese, Vietnamese) 4. Indian (note different areas) 5. African (different countries) 6. Southern US 7. Middle Eastern 8. African American 9. Alaskan Native, Native American. 2) Create a table, or brief summary highlighting these different types of Cultural Diets Nutritional Restrictions, What foods are Most Common in Their Diets, What Seasonings do They Use Most Often, and What Nutritional Deficiencies...
Record the data. In class, randomly pick one person. On the class list, mark that person’s...
Record the data. In class, randomly pick one person. On the class list, mark that person’s name. Move down four names on the class list. Mark that person’s name. Continue doing this until you have marked 12 names. You may need to go back to the start of the list. For each marked name record the five data values. You now have a total of 60 data values. For each name marked, record the data. 5 3 0 0 0...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT