Question

Naming should help to distinguish between a variable and a constant. How should you be able...

Naming should help to distinguish between a variable and a constant. How should you be able to tell them apart?

Binary operators are pretty easy, but for the unary operators, what do you need to remember about the differences between prefixing and postfixing an increment or decrement operator?

What is the key element of syntax to remember when using a shortcut assignment operator?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

variable : We can change the value of the variable with another value then the varible will hold the new value

Ex: int a=10; // See now the variable 'a' is holding the value 10

a=20 // we assigned 20 to the variable.So the value 10 is replaced with 20.

Now the value inside the variable a is 20

Constant: here we cant replace or reassign the variable with another value once declared and assigned a value.

Ex: final int a=10 ; See now the variable 'a' is holding the value 10

a=20 // Which is incorrect.it wont give us a chance to reassign the variable with new value.

====================

2)

Binary operators: generally we use binary operators to act on two operands.

like a + b, a * b etc

But coming to the Uninary operators , these are the operators which act on single variables.

Ex: int a=10 ; // The variable a is holding the value 10

++a; this is the prefix increment operation. As the increment of the value is done before the assignment

a++; this is the post fix increment operation. As the increment of the value is done after the assignment.

Like in the same way we have prefix and postfix decrement operators.

--a; this is the prefix decrement operation. As the decrement of the value is done before the assignment

a--; this is the postfix decrement operation. As the decrement of the value is done after the assignment

=====================

We can use shortcut assignment operator in arithmetic operations.

Ex: +=, -=, *=, /=

a+=5 ; This is same as a= a+5;

a-=5 ; this is same as a=a-5;

========================Thank You

Add a comment
Know the answer?
Add Answer to:
Naming should help to distinguish between a variable and a constant. How should you be able...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Question Your class should support the following operations on Fraction objects: • Construction of a...

    C++ Question Your class should support the following operations on Fraction objects: • Construction of a Fraction from two, one, or zero integer arguments. If two arguments, they are assumed to be the numerator and denominator, just one is assumed to be a whole number, and zero arguments creates a zero Fraction. Use default parameters so that you only need a single function to implement all three of these constructors. You should check to make sure that the denominator is...

  • Can someone please help me with how to write this in Java? You will write a...

    Can someone please help me with how to write this in Java? You will write a program to evaluate a math expression given by a user. • Read the input from the scanner • Expressions should match the forms below. Note that you will need spaces between the numbers and operators for your scanner methods to work best. - “number1 operator number2” - “operator number1” • Declare number1 and number2 as type integer. Test using integer values. • You must...

  • Overview This checkpoint is intended to help you practice the syntax of operator overloading with member...

    Overview This checkpoint is intended to help you practice the syntax of operator overloading with member functions in C++. You will work with the same money class that you did in Checkpoint A, implementing a few more operators. Instructions Begin with a working (but simplistic) implementation of a Money class that contains integer values for dollars and cents. Here is my code: /********************* * File: check12b.cpp *********************/ #include using namespace std; #include "money.h" /**************************************************************** * Function: main * Purpose: Test...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • Homework #1 – Implementing Set with a Linked List Project Objectives 1. Be able to integrate...

    Homework #1 – Implementing Set with a Linked List Project Objectives 1. Be able to integrate the knowledge of Java Generics, Collection Framework and the Linked List data structure to implement the Set ADT. Components emphasized are: • Allowing parameterized type for handling a general class of values in the collection framework; • Understanding conceptual differences between lists and sets and implementing them with methods; • Implementation of an iterator with functionality that is appropriate for the collection, namely the...

  • C++. Need some help getting started. We will also have the following two functions: 1. A...

    C++. Need some help getting started. We will also have the following two functions: 1. A mutate function that randomly modifies a chromosome. 2. A crossover function that takes two chromosomes and splits each one at the same spot, then combines them together. Our genetic algorithm works by iterating over generations of chromosomes via the following process: 1. Generate random population. 2. Until we get an answer that is good enough, do the next steps in a loop: (a) Do...

  • Aim: By working on this assignment you should be able to: ● Create and use dynamic arrays ● Create, manipulate and store...

    Aim: By working on this assignment you should be able to: ● Create and use dynamic arrays ● Create, manipulate and store input in c-style strings ● Accept and parse command-line arguments ● Implement recursion About this assignment: For this assignment, you will design and implement a game. You can pick between minesweeper or battleship. If you turn in both, you will get whichever scores the highest points. If you submit the design for one option, but code for another,...

  • Task The task for this assignment is to have the following user-defined data type: struct rgb...

    Task The task for this assignment is to have the following user-defined data type: struct rgb { unsigned char red; unsigned char green; unsigned char blue; }; be able to be: read in from a stream (e.g., std::cin), i.e., write: std::istream& operator >>(std::istream& is, rgb& colour); (see below) written out to a stream (e.g., std::cout), i.e., write: std::ostream& operator <<(std::ostream& os, rgb const& colour); (see below) stored in a container, e.g., std::vector<rgb>, std::array<rgb,16>; (see below) processed via algorithms (and other...

  • Game Development: Uno For this assignment you will be creating the game of Uno (See the...

    Game Development: Uno For this assignment you will be creating the game of Uno (See the accompanying pdf for the instructions of the game). Your version will adhere to all the rules except that only the next player can issue a challenge against the previous player in regards to penalties, and your games must have at least three (3) players and at most nine (9) players. To begin, you must create the class Card which contains: Private string field named...

  • The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this sof...

    The Acme Trucking company has hired you to write software to help dispatch its trucks. One important element of this software is knowing the distance between any two cities that it services. Design and implement a Distance class that stores the distances between cities in a two-dimensional array. This class contains the following required data members and methods: Required Data Members: String[] cities; //it is used to store city names int[][] distance; // this 2-D array repreents distance between two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT