A
arnuld
STATEMENT: Write a program that prompts the user for two numbers and
writes each number in the range specified by the two numbers to the
standard output. Revise the program so that it never prints more than
10 numbers per line.
i have written the 1st part of it which prints the range:
#include <iostream>
int main()
{
std::cout << "Enter 2 numbers: ";
int v1, v2;
std::cin >> v1 >> v2;
int lower,upper;
if(v1 <= v2)
{
lower = v1;
upper = v2;
}
else
{
lower = v2;
upper = v1;
}
for(int i=lower; i <= upper; ++i)
std::cout << i
<<" "; // space between two numbers
std:: cout << "\nThank you ;-)" << std::endl;
}
it works but i am not able to print 10 numbers per line. i tried to
embed a for loop within the original for loop i used in the programme
but that does not work.
any hints ?
writes each number in the range specified by the two numbers to the
standard output. Revise the program so that it never prints more than
10 numbers per line.
i have written the 1st part of it which prints the range:
#include <iostream>
int main()
{
std::cout << "Enter 2 numbers: ";
int v1, v2;
std::cin >> v1 >> v2;
int lower,upper;
if(v1 <= v2)
{
lower = v1;
upper = v2;
}
else
{
lower = v2;
upper = v1;
}
for(int i=lower; i <= upper; ++i)
std::cout << i
<<" "; // space between two numbers
std:: cout << "\nThank you ;-)" << std::endl;
}
it works but i am not able to print 10 numbers per line. i tried to
embed a for loop within the original for loop i used in the programme
but that does not work.
any hints ?