What do the loops print

Assignment Help C/C++ Programming
Reference no: EM13165680

What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n <= 5; n++) { s = s + n; System.out.print(s + " "); }
b. int s = 1; for (int n = 1; s <= 10; System.out.print(s + " ")) { n = n + 2; s = s + n; } c. int s = 1; int n; for (n = 1; n <= 5; n++) { s = s + n; n++; } System.out.print(s + " " + n);

6.19 What do the following program segments print? Find the answers by tracing the code, not by using the computer.
a. int n = 1; for (int i = 2; i < 5; i++) { n = n + i; } System.out.print(n);
b. int i; double n = 1 / 2; for (i = 2; i <= 5; i++) { n = n + 1.0 / i; } System.out.print(i);
c. double x = 1; double y = 1; int i = 0; do { y = y / 2; x = x + y; i++; } while (x < 1.8); System.out.print(i);
d. double x = 1; double y = 1; int i = 0; while (y >= 1.5) { x = x / 2; y = x + y; i++; } System.out.print(i);

 

Reference no: EM13165680

Questions Cloud

A java program where the user designates : a java program where the user designates how many games they would like to play (for example user inputs 10 games) then they play the game, if lets say there is a tie after 10 games the game continues until either the user of the computer wins by 2
What happens when you assign : What happens when you assign 340,282,343,598.33 to a Single variable? Assuming that the variable in question is named sngNumber and you execute the statement MessageBox.Show
Supposed to swap numbers : The program is supposed to swap numbers, but I am stuck something is wrong! It does not swap them it repeats the second number, please help to fix! Thanks, this is in C++.
The imperial system of measurements : The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.
What do the loops print : What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n
The ieee 754 single precision binary representation : What would be the IEEE 754 single precision binary representation of the floating point value -314159265. 3589 ? Express your final answer as an 8-hex-digit number and explain how your answer was obtained for full credit.
Child process to take the role of the number guesser : Write a program in C that takes a number between 1 and 1024 as input on the command line, and then forks a child process to take the role of the number guesser
Assume that a student table in a university : Assume that a student table in a university database has an index on StudentID (the primary key). and additional indexes on Major, Age, Marital status, and HomeZipCode.
Prepare a multiple-step income statement for 2010 : Prepare a multiple-step income statement for 2010 for Howell Corporation that is presented in accordance with generally accepted accounting principles

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd