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

  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