Question

1.What is the difference between prefix and postfix mode for the increment and decrement operators? Give...

1.What is the difference between prefix and postfix mode for the increment and decrement operators? Give examples of each.

2.How would you prevent infinite loops in a “while” loop statement? Give an example of an infinite while loop.

3.Give an example of a simple “for” loop.

4.What is a “sentinel” used for?

5.Give an example of the “open” member function to open a file.

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

1) prefix increment/decrement changes the value before the expression is evaluated,postfix increment/decrement changes the value after it has to do with the way the post increment operator works,it returns the value of I and then increments the value

Ex pg1 main()

{ into a=5,b;

b=++a +5; printf("a=%d,b=%d",a,b);}

Result a=a+1 a as 6,then b becomes b=6+5=11 so a=6,b=11

Pg2 main()

{ into a=5,b; b=a++ +5;printf ("a=%@d,b=%d",a,b);}

b=5+5=10 a=a+1,makes value of a as 6 so a=6 b=10

2)<HTML> <head> <title> your first PHP while loop!</title ><head><body><?php $loopcond=true;

While($loopcond==true){//echo your message that the loop is running below echo"<p> The loop is running <p>";}$loopcond=false; echo"<p> and now its done /p>";>? </body>. </HTML> since to exit the loop you will need to make the condition in the while loop evaluate to false,you will have to set $loopcond to false and the variable assignment should be done inside the while loop,

While($loopcond==true){//echo msg

Echo "<p> the loop is running <p>"; $loopcond=false;

3)for loop syntax for(initialization; condition test;increment or decrement)

{//code}

Int I; for (i"=1; i <=3; i ++)

{ printf ("hello,world")}

4)A senitel node is a specifically designated node used with linked lists and trees as a traversal path terminator,this type of node doesx not hold or reference any data managed by the data structure

Ex: strict sll_node {// int key; study all_node *next; ,}

Sll, *first;

Add a comment
Know the answer?
Add Answer to:
1.What is the difference between prefix and postfix mode for the increment and decrement operators? Give...
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
  • 256 Chapter 4 Loops and Files Review Questions and Exercises Multiple Choice and True/False 1. What...

    256 Chapter 4 Loops and Files Review Questions and Exercises Multiple Choice and True/False 1. What will the printin statement in the following program segment displays int x = 5; System.out.println(x++): b. 6 c. O d. None of these What will the printin statement in the following program segment display? int x = 5: System.out.println(+*x): a. 3 b. 6 C.O d. None of these 3. In the expression number++, the ++ operator is in what mode? a. prefix b. pretest...

  • Questions 1. How to create a comment in python? 2. The way to obtain user input...

    Questions 1. How to create a comment in python? 2. The way to obtain user input from command line 3. List standard mathematical operators in python and explain them 4. List comparison operators in python 5. Explain while loop. Give example 6. Explain for loop. Give example 7. How to create infinite loop? And how to stop it? 8. Explain a built-in function ‘range’ for ‘for’ loop 9. Explain break statement 10. Explain continue statement 11. Explain pass statement 12....

  • 1. What is the difference between 1-mode and 2-mode graph? Give an example for each. 2....

    1. What is the difference between 1-mode and 2-mode graph? Give an example for each. 2. List various graph data structures to store social network information. 3. What is “six degrees of separation” in the context of social networks? What is the average degree of separation for Facebook and Twitter (you can cite other studies that have reported these statistics)? 4. What is “strength of weak ties”? Explain the rationale behind this phenomenon. 5. List and describe the various centrality...

  • Can you please explain what does each sentence mean and give an example if it’s possible?....

    Can you please explain what does each sentence mean and give an example if it’s possible?. I need to have answers for all of them please Assignment Statements- Input- cin >> Output--cout << endl<"n" Output formatting Arithmetic operators +-'* / % Relational Operators-=-= ++- Logical Operators ! && II Evaluating Expressions of mixed type Evaluating Boolean Expressions Type Conversion, Implicit Coersion Explicit-Type Casting Control Structure: Sequence, decision (branching), looping (repetition) if, if-else, if/else-if/else, nested ifs switch statement conditional statement while...

  • Repetition What are the advantages and disadvantages of the list box? when should a list box...

    Repetition What are the advantages and disadvantages of the list box? when should a list box be used? Describe some guidelines for when to use a list box. What is the difference between a pretest and posttest Do...loop statement? give an example of each loop using pseudocode. What is infinite loop, how to avoid your program runs with an endless loop? give an example

  • What is the difference between simple linear and multiple regressions? Give an example of a situation...

    What is the difference between simple linear and multiple regressions? Give an example of a situation where linear regression might be useful Give an example of a situation where multiple regression might be useful.

  • 1. What is the difference between an electrolyte and a nonelectrolyte? Give one example of each...

    1. What is the difference between an electrolyte and a nonelectrolyte? Give one example of each type 2. What is the difference between a strong electrolyte and a weak electrolyte? Give one example of each type.

  • . What is the difference between a minor surgery and a major surgery? Give at least...

    . What is the difference between a minor surgery and a major surgery? Give at least 5 examples of each. What is the importance of medical clearance in an individual before submitting the patient to a major surgery?  As a registered nurse how are you going to prepare the patient physically and emotionally before surgery?  A patient was admitted to Unit 4 less than 24 hours who is status post abdominal surgery. Give at least three possible complications post-operatively as a result...

  • give a brief description of the difference between a strong acid and a weak acid Name...

    give a brief description of the difference between a strong acid and a weak acid Name Section Acids, Bases and Antacids * MS Experiment #8 Prelab Exercise Give a brief description of the differ a for each). A strong a strong acid and one example of a weak acid one exampy alone and is one which specific chemical Solution, whereas a weak acid ligsociet 30 urov n om ciate into H+ ion in aqueous solution Example of strong and chlo...

  • What is the difference between a current asset and a long‐term asset? Why is cash typically...

    What is the difference between a current asset and a long‐term asset? Why is cash typically listed first on a balance sheet? List and explain the major items found on an income statement. What is accrual accounting? Give an example of how accrual accounting affects a company's financial statement. List the four categories of financial ratios and give an example of each. What is the purpose of ratio analysis? What is a cash budget? Briefly outline what a simple cash...

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