Question

In: Computer Science

When a variable is declared, it may also be initialized (given its initial – meaning first...

When a variable is declared, it may also be initialized (given its initial – meaning first – value) using the assignment operator (an equals sign). What is the initial value of cupSize?

Solutions

Expert Solution

THOUGH THIS QUESTION IS INCOMPLETE, I AM PROVIDING THE SOLUTION AS PER DIFFERENT PROGRAMMING LANGUAGES:

1. C/C++

C/C++ does not initialize most variables to a default value (mostly zero) automatically. When a variable is declared , it is assigned a memory location by the compiler and the default value of that variable is a garbage or junk value.

Example;

int A;

cout<<A;

Or

printf("%d",A);

This will display any garbage value in A

2. Python

In Python, A variable needs some inital value otherwise "name is not defined" error is displayed.

Example:

A

print(A)

will cause name not defined error

OUTPUT WILL BE: NameError: name 'A' is not defined  

3. JAVA

In Java, the program will run and throw a runtime error as follows:

int a;
System.out.print(a);

Following error is displayed once the program is run:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - variable a might not have been initialized  


Related Solutions

How do I get the first initial of a first, middle, and last name? Also when...
How do I get the first initial of a first, middle, and last name? Also when I look to count characters in the name I want to be abel to count the spaces in-between the names how can i do this?
Given a String variable named sentence that has been initialized, write an expression whose value is...
Given a String variable named sentence that has been initialized, write an expression whose value is the the very last character in the String referred to by sentence. write it in python
What is the meaning of calculating the "flux" when solving integrals? - Also; What is the...
What is the meaning of calculating the "flux" when solving integrals? - Also; What is the difference between these integrals? -Line integral -Double integral -Triple integral -Surface integral -Flux, flux integral
Assume that an int variable age has been declared and already given a value and assume...
Assume that an int variable age has been declared and already given a value and assume that a char variable choice has been declared as well. Assume further that the user has just been presented with the following menu: S: hangar steak, red potatoes, asparagus T: whole trout, long rice, brussel sprouts B: cheddar cheeseburger, steak fries, cole slaw (Yes, this menu really IS a menu!) Write some code that reads a single character (S or T or B) into...
Given a building its initial value is 2,000,000 SR at the first 5 years simple interest...
Given a building its initial value is 2,000,000 SR at the first 5 years simple interest rate is = 10 % and at the second 5 years compound interest rate is = 8 %. 1) Find the future value of this building after: A) 7 years old, and B)10 years old. 2) If the future value of this building after 10 years is 4,000,000 SR find its initial value now. 3) If the initial value is 2,000,000 SR and future...
What is the meaning torsion of structure when it is at first mode ? please explain...
What is the meaning torsion of structure when it is at first mode ? please explain detailedly.
An English word is called palindrome if its meaning may be interpreted the same way in...
An English word is called palindrome if its meaning may be interpreted the same way in either forward or reverse direction. Some examples of common palindromic words: civic, radar, level, rotor, noon, etc. Design an algorithm that takes a word as input and decides if the input word is palindrome. In your algorithm, a stack should be used. Describe the pseudo-code of your algorithm. What is the time complexity of your algorithm in big-O? PLEAS USE PSEUDO-CODE.
President Wilson declared the United States neutral when WWI first broke out, but eventually led the...
President Wilson declared the United States neutral when WWI first broke out, but eventually led the country into war. Why did the United States decide to participate in the war and what effect American entry have on the allied war effort?
Develop a least-squares estimated regression line. Also, compute the coefficient of determination and explain its meaning....
Develop a least-squares estimated regression line. Also, compute the coefficient of determination and explain its meaning. Price (x) Units sold (y) 34 4 36 4 32 6 35 5 31 9 38 2 39 1
Develop a least-squares estimated regression line. Also, compute the coefficient of determination and explain its meaning....
Develop a least-squares estimated regression line. Also, compute the coefficient of determination and explain its meaning. Price (x) Units sold (y) 34 4 36 4 32 6 35 5 31 9 38 2 39 1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT