What is the bug or logic error in the above program

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

I'm just beginning basic programming and need the most basic syntax possible. We've only gone as far as loops and here are two example questions I need you to code similarly to. BTW this is a loop lab, so there will be a for, while, etc. loop and maybe an if statement. Please use Visual Studio if possible because that is what we are required to use, but if you can code exactly the same in NetBeans go for it.

1.) Write a program to print the following numbers:

5 10 15 20 25 30 35

#include<iostream>
usingnamespace std;
int main()
{
for (int i = 5; i <= 35; i += 5) {
cout << i << endl;
}
system("pause");
}

2.) Write code that will ask the user to input a number between (50-100) and print how many odd & even numbers between that number and 200.

#include<iostream>
usingnamespace std;
int main()
{
int evens = 0;
int odds = 0;
int val = 0;
cout << "Enter a number between 50-100: " << endl;
cin >> val;
while (val < 200) {
if (val % 2 == 1) odds++;
else evens++;
val++;
}
cout << odds << endl;
cout << evens << endl;
system("pause");
}

THE REAL QUESTIONS

1.) Write code that will ask the user to input a 4 digit code say "3456" à Drive the user crazy by insisting they entered a wrong code even if they entered the correct code!! After 3 attempts, display a message telling the user you were messing with them! And they are now logged in.

2.) 1. Write code that will print the square roots of the first 25 odd positive integers.For each odd number print the following sentence: The square root of __ is __.

3.) Try to run the following program at https://cpp.sh/

#include <iostream>
using namespace std;
int main()
{
int hour;
int min;
for (hour = 1; hour <= 11; hour++)
{
for (min = 0; min <= 59; min++)
{
cout << hour << ":" << min << "AM" << endl;
}
}
system("pause");
return 0;
}

1. What is the bug or logic error in the above program?

2. Add the lines to fix it.

3. This is an example of __nested__________ loops.

4. How many times does the outer loop execute?

5. How many times does the inner loop execute?

6. Make the times more accurate by adding lines of code to print seconds.

Reference no: EM13759257

Questions Cloud

Monetary base and the banks reserve ratio : Calculate the monetary base and the banks reserve ratio. - Calculate the total money creation in the economy with the help of formula.
Compatibility of strategies at the corporate-unit : The compatibility of strategies at the corporate, unit, and functional levels. Are Hiller’s general business strategy (buying distressed, undervalued properties and turning them around for eventual sale) and their human resource (HR) strategy compati..
Strategy for addressing the associated risk : For each of the three (3) or more malicious attacks and / or threats that you identified in Assignment, choose a strategy for addressing the associated risk (i.e., risk mitigation, risk assignment, risk acceptance, or risk avoidance). Explain your..
Explain deduction-taxability of compensation : Explain "Deduction- Taxability of Compensation" (It is related HR employee benefie, qualify plan question)
What is the bug or logic error in the above program : What is the bug or logic error in the above program. Add the lines to fix it. This is an example of __nested__________ loops. How many times does the outer loop execute
Sustain the westwards competitive advantage : Prepare a Five Forces Analysis and make a determination as to whether Hiller can sustain the Westward’s competitive advantage (should it choose to retain the property)
Designing a quality control-what will be the critical value : You are designing a quality control system for the waiting time to see a doctor in the emergency room for the TMC. (Toledo Medical Center). You are taking samples of size n on the hour every hour, measure the average time for the “most” recent n pati..
Potential logical threats that require attention : Information Systems Security, Suppose you are the IT professional in charge of security for a small pharmacy that has recently opened within a shopping mall. Determine the impact of at least five (5) potential logical threats that require attention
What will be the new confidence interval : Suppose that the confidence interval for the population mean of summer income of undergraduate fulltime students using a sample size of 50, confidence level of 0.9 is [7000,10000]. If you increase the confidence level to 0.95, all other things remain..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Function that has three inputs which are integers

Write a C++ function that has three inputs which are integers. The function returns true if the first number raised to the power of the second number equals the third number.

  Display a year-by-year depreciation schedule

Create GUI screen interface that accepts input and shows output and resize the GUI screen & the list box to best fit the output displayed

  Write function compute square root together with prototype

Write a C++ function called compute together with its prototype that is passed 2 integers, A and B and returns the square root of A2+B2 ,as a double.

  Find the area of the circle

What is the ratio of the areas of the inscribed circle to that of the unit square -

  Write a recursive function

Write a recursive function, vowels, that returns the number of vowels in a string and write the definitions of the functions to overload the operators defined in parts a to c.

  Where can grep be found for windows for linux

What is grep? Where can grep be found for Windows? For Linux?

  Write a program that uses the following arrays empid an

write a program that uses the following arrays empid an array of seven long integers to hold employee identification

  Public transport fare ticketing system

Implement and test a public transport fare ticketing system.

  A constructor that constructs a rectangle2d

A constructor that constructs a Rectangle2D with specified points as coordinates.A no-argument constructor that creates the rectangle with points (0, 0), (5, 5) and (0, 5) and

  Find the average of four 16-bit unsigned integers

Write a program (starting at address $4000) to find the average of four 16-bit unsigned integers stored at locations $5000, $5002, $5004 and $5006 and store the 16-bit result at location $5010.

  Where c is the temperature in degrees celsius

Write a program that takes as input a depth in kilometers inside the earth and displays the temperature at this depth in degrees Celsius and in degrees Fahrenheit.

  Longest increasing subsequence problem

Write a computer program to solve the Longest Increasing Subsequence problem.Your program should read input from a text file (one value per line

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