What is a constant? Explain with an example.
Answer / Pratibha Yadav
In C++, a constant is a variable whose value cannot be changed during the execution of the program. It is also known as a literal.nnThere are four types of constants in C++:n1) Integer Constants: Examples include 42, 0xFF (hexadecimal), and 3'000'000 (cube notation).n2) Floating-Point Constants: Examples include 3.14159 (decimal), 6e-7f (exponential notation for floating-point numbers), and 0xf0p-2 (binary floating-point number with mantissa and exponent parts).n3) Character Constants: A character constant is enclosed in single quotes, like 'a' or 't'.n4) String Literals: A string literal is a sequence of characters enclosed in double quotes, like "Hello, World!".nnA const variable can be declared by adding the keyword const before its type. For example, `const int my_constant = 42;`
| Is This Answer Correct ? | 0 Yes | 0 No |
Specify different types of decision control statements?
What should main() return in c and c++?
What is the role of C++ shorthand's?
Mention the ways in which parameterized can be invoked.
What is the difference between map and hashmap in c++?
When one must use recursion function? Mention what happens when recursion functions are declared inline?
What is jump statement in C++?
What is virtual destructor? What is its use?
Write a program to swap 2 chars without using a third varable? char *s = "A"; char *p = "B";
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
Explain the concept of memory leak?
Must accepts "Maestro Cards" Tax for bike should be less than 15 Total number of lanes is more than 10 Must provides monthly pass Write a method: boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes); String[] cardsAccepted A String array of names of card types accepted for payment of toll tax, it can be null if the toll does not accept any card String[] tollTax A String array of toll tax chart (say “Train : 300â€Â,â€ÂBullCart : 10â€Â) boolean hasMonthlyPass This parameter defines whether there is any monthly pass available or not int numberOfLanes This parameter defines the number of lanes for each side