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

  Use gets() to input the user name into name

Use strcpy() and strcat() to build the anwer into fullname that consists of.

  Program of a class date which displays the date

Write a C++ program of a Class Date which displays the date. Use the subsequent requirements:

  Write song playlist class-object-oriented design principles

Write a song playlist class in C++ called "PlayList" using object-oriented design principles. The playlist should support the following ADT.The implementation should be based on an array of strings to store the song titles.

  Write a program that skip s leading whitespace character

a) Write a program that skip s leading whitespace character s in each line of the pro vided data file CPPHumor .txt . Save the results in a new file

  Write programme that allows a user to enter distinct words

Write a programme that allows a user to enter three distinct words and returns them as a single string

  Modify the program to detect and report

Syntax errors including mismatched parentheses, invalid operator, missing comma, semicolon or assignment operator should be reported as a syntax error and the program should proceed to the next expression.

  Recursive method void printrevers

Write a c language program and I also need executable file for this program - Write a recursive method

  1 write a c program to display the following sum4 812162024

1. write a c program to display the following sum4 812162024 ...4042. write a program that will convert us dollar

  Write a program that takes a string as input

Write a program that takes a string as input (from the user) and then reverses the contents of the string. Your program should work by using two pointers.

  Define a class for a type called fraction

Define a class for a type called Fraction. This class is used to represent a ratio of two integers. Include mutator functions that allow the user to set the numerator and the denominator.

  Make an explicit statement of the invariant of the set class

Prepare a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, you'll need to change the interface a bit.

  Write a program that reads in babynames

Write a program that reads in babynames.txt and produces two files - Separate the data for the boys and girls. You may enter any names

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