How many time is loop body of while statement executed

Assignment Help Programming Languages
Reference no: EM13690147

Refer the following program segment.

Question: Assume that all variables are of type int. z = 0; g = 0; s = 0; i = 0; while (i < 50){ scanf (“%d”, &t); s = s + t; if (t >= 0) g = g + 1; else z = z + 1; i = i + 1; }

Part 1.How many time is the loop body of the while statement executed? a) once, b) never, c) 49 times, d) 50 times, e) until a number 50 or larger is entered

Part -2 .The value stored in variable s at the end of the execution of the loop could best be described as a) the average of the numbers scanned, b) the sum of the numbers scanned, c) the largest of the numbers scanned, d) how many numbers were scanned, e) the sentinel value

Part 3.The value stored in variable z at the end of the execution of the loop could best be described. a) how many positive items were scanned, b) the sum of all positive items scanned, c) how many negative items were scanned, d) the sum of all negative items scanned, e) the sentinel value

Part 4.The loop can best be categorized as a. a) counter-controlled loop, b) sentinel-controlled loop, c) loop that computes a product, d) general condition loop, e) non of the above

Explain each and every part in depth with examples.

Reference no: EM13690147

Questions Cloud

Theory also suggests a relationship-arithmetic average : Using the file FARM.csv. Construct the variable Q = (PBARL*QL + PBARC*QC + PBARO*QO)/10 where PBARL, PBARC and PBARO are the arithmetic averages of PL, PC and PO respectively.
Contains data on output quantities and input quantities : The file FARM.csv contains data on output quantities (QL, QC and QO), input quantities (XK, XL, XA and XM) and environmental variables (ZD and ZR) for 11 states in the Northeast Farm Production Region of the U.S.
Find the socially optimum output in both periods : Let the social discount rate equal 10%. Find the socially optimum output in both periods. Calculate the Dead Weight Loss of the unrestricted equilibrium.
Describe the output of the series of stack operations : Describe the output of the series of stack operations: push(5), push(3), push(2), push(8), pop(), top(), push(9), push(1), pop(), push(7), push(6), top(), pop(), push(4), pop()
How many time is loop body of while statement executed : How many time is the loop body of the while statement executed? a) once, b) never, c) 49 times, d) 50 times, e) until a number 50 or larger is entered
Charges and electron dots as needed on each ion : To add formal charges, click the button below (which will turn yellow when activated) before clicking on the molecule. You may need to hit Enter on your keyboard after typing the charge to make it register before clicking submit. Place charges and..
Create a two-dimensional array : Describe a problem where you might need to create a two-dimensional array to accurately model the data, and describe how you would use the data to help solve the problem.
Reverse the order of the characters in the string : Write a program which will perform the following " using MARS - Assembly language"
Explain why would it be important to place the same amount : Problem- Why would it be important to place the same amount of a solution in the polarimeter tube when measuring optical rotation as the amount of solvent when measuring the blank

Reviews

Write a Review

Programming Languages Questions & Answers

  Probability line is executed in nth iteration of for loop

What is the probability that line is executed during the nth iteration of the for loop? What is the exact expected number of executions of line?

  Program that prompts user to enter five test scores

Write the algorithm for a program that prompts the user to enter five test scores.

  Projects for the falling letters game

Design and implement two projects for the Falling Letters game using C# and Windows Presentation Foundation (WPF) template in Visual Studio 2012 or newer.

  Define function that takes year as it-s input argument

Define and call a function fast_food_billions that takes the year as it's input argument and returns the prediction as it's result. Tell the user that entry of a year before 2005 will cause the program to stop.

  Draw and implement class which contains instance data

Draw and Implement the class called "Box" which contains instance data (all doubles) that represents height, width, and depth of the box. Also include boolean variable called "full" as instance.

  Tic-tac-toe game

You have gathered your information on the AI for the Tic-Tac-Toe game and began to develop your own ways to improve it using C++. Now, it's time to present your findings in a final paper. Remember that your final analysis and recommendations m..

  Assembly language instructions into machine code

The assembly instructions are stored in a file. Each line of the file stores exactly oneinstruction. The name of the file should be provided to the program as a command line argument.

  Develop a functional web-based application for a calculator

Develop a functional web-based application for a calculator. It does not need to be live; you can provide JavaScript, CSS, and HTML files. The calculator should successfully complete addition, subtraction, multiplication, and division operations.

  Design electronic submission of assignments from students

This system must manage electronic submission of assignments from students to instructors. It must keep track of which students have submitted assignments and must allow instructors to manage the grading.

  Explain overriding method

Assuming the class B inherits from class A and method foo belongs to class A, what do we mean by overriding method foo in class B? We are coding another version of method foo in class B

  Estimate the storage space for telephone book

Estimate the storage space (number of bytes) required for each of the following items: A telephone book with 10,000 entries consisting of names, addresses and phone numbers. Use your phone book to estimate the average length of an entry.

  Create test application that creates objects of type book

Create a test application that creates several objects of type book class and adds each Book to an ArrayList. Your test application should then do the following.

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