Question

Why is it important to initialize the loop control variable for WHILE loops? What does the...

Why is it important to initialize the loop control variable for WHILE loops?

What does the parameter in the function call below do?

doStuff(**z);

What is the difference between function overloading and Default arguments?

Of the two techniques in No. 7, when would you use one over the other?

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

Why is it important to initialize the loop control variable for WHILE loops?

For counting while loop it is very important to initialize the control variable because if don't initialize then loop wont execute.

Example :

int a=1;

while(a<=5)

{

cout<<a<<" ";

a++;

}

here a is initialized with 1 so if you wont initialize the a then while loop wont be executed due its condition.

What does the parameter in the function call below do?

doStuff(**z);

It is a declaration of data function (doStuff) with one parameter which is a pointer to pointer means it is pointing the value of a pointer variable which has address of another pointer variable in it.  

What is the difference between function overloading and Default arguments?

Function overloading - A function overloading is a compile-time polymorphism in which one class has many functions with same name but different signature.

Syntax : (Here, functionName is same for both the definition ,returntype or parameters may vary)

returntype functionName()

{

}

returntype functionName(datatype variableName)

{

}

Default arguments - Default arguments are the values provided in a function declaration that assigned values to the formal variables.

Syntax :

returntype functionaname(datatype variableName=value)

{

}

Note : You haven't mentioned No.7 question or two techniques

"Of the two techniques in No. 7, when would you use one over the other?"

Add a comment
Know the answer?
Add Answer to:
Why is it important to initialize the loop control variable for WHILE loops? What does the...
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
  • PLEASE USE WHILE LOOP (NOT FOR LOOPS). Python programming. In this problem, you should write one...

    PLEASE USE WHILE LOOP (NOT FOR LOOPS). Python programming. In this problem, you should write one function named multiply. This function should accept one parameter, which you can assume will be a list with one or more integers in it. (If you don’t know what I mean when I say “list of integers”, go do the reading!) The function should loop through all of the numbers in the list, and multiply all of the numbers together. It should return the...

  • Evaluate Exponent: Declare a double variable called result and initialize it to 1.0; Ask the user...

    Evaluate Exponent: Declare a double variable called result and initialize it to 1.0; Ask the user for two values - one for the base, and the other for the exponent. If the exponent parameter is 0, give the user an error. You do not need to handle a negative exponent value. Otherwise, declare an integer variable called loop and initialize it to 0 Write a do while loop as follows: Inside the loop: Multiply the results times the number Increment...

  • Why main() method is always static, void and public? What is the assignment compatibility and why...

    Why main() method is always static, void and public? What is the assignment compatibility and why is it necessary? Why floating-point numbers have round-off errors? What are good programming styles? Some predefined Classes with mostly static methods and purposes of some of these methods. Commonly used String Class methods. What are trade-offs between ifstatements and switchstatements? What operators have Right-to-Left Associativity? What are expression side effects and what are their trade-offs? What is the difference(s) between while loops and do-while...

  • What control structure does Java use to process all elements in a collection? A do-while loop....

    What control structure does Java use to process all elements in a collection? A do-while loop. A for loop. A for-each loop. A while loop. Which of the following is a valid Java array declaration? String array s[10]; String[] s; String[10] s; Array String[] s; Which of the following references will get the last element in an array of n elements named a? a[n-1] a[n] a[n+1] a

  • Need help with implementing a While, Do-while and for loops in a program. UML: - scnr...

    Need help with implementing a While, Do-while and for loops in a program. UML: - scnr : Scanner - rows : int - MAX_ASCII : int ------------------------------------------------------------------------------- + CharacterTables() : + CharacterTables(rows : int) : - getStartingValue() : int -displayTable(startValue : int) : void - userContinue() : boolean + main(args : String[]) : void In Section 5.10 we saw that there is a close relationship between char and int. Variables of type char store numbers. (Actually, variables of all types...

  • In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops...

    In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops for the input validations required: number of employees(cannot be less than 1) and number of days any employee missed(cannot be a negative number, 0 is valid.) Each function needs a separate flowchart. The function charts are not connected to main with flowlines. main will have the usual start and end symbols. The other three functions should indicate the parameters, if any, in start; and...

  • 1. Why does money have a time value? Why is it important? 2. Discuss whether the...

    1. Why does money have a time value? Why is it important? 2. Discuss whether the standard deviation of a portfolio is, or is not, a weighted average of the standard deviations of the assets in the portfolio. Fully explain your answer. 3. You want to invest in bonds. Explain whether or not each provision listed will make the bonds more or less desirable as an investment: call provision, convertible bond provision, and subordinated debt. 4. What is the difference...

  • Explain what each of the following instructions does. ifstream some_data some_data.open("my_stufr.dat"); ofstream more_data. more_data.open("other_sluff.dat"); Given the...

    Explain what each of the following instructions does. ifstream some_data some_data.open("my_stufr.dat"); ofstream more_data. more_data.open("other_sluff.dat"); Given the instructions in the previous problem, write each of the follow pieces of a program. Write a loop that will read doubles from the input file. Each number will be put into a variable named the_number and then added to a variable named the_total. When the end of file is reached, print the number using cout. Write a loop that will read strings from cin...

  • 5. What does the standard I/O library function int getchar() do? Why does it return an...

    5. What does the standard I/O library function int getchar() do? Why does it return an int? 6. What is the difference between the standard 10 library functions scanf().fscanf(), and sscanf()? 7. What do the functions scanf(), fscanf(), and sscanf() return? 8. What does the stdlib library function system) do?

  • 4. What is the structure and function of ATP? Why is it important that ATP can...

    4. What is the structure and function of ATP? Why is it important that ATP can be regenerated? 5. What is photosynthesis? What is the chemical equation of photosynthesis? 6. What do we call organisms that are able to undergo photosynthesis? 7. How do the reactants CO2 and H2O reach the chloroplasts in the leaves?

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
ADVERTISEMENT