Three Basic C++ Loop Statements

Three Basic C++ Loop Statements

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 __.

Place your order now with Reliablepapers.com
and experience the difference of letting the professionals do the work for you!
Our Process is Simple
Our Simple process

Order Now

Place Order