+ 1
Please help me to answer this question
i want enter tow numbers and create this output for example: user enter 4 and 9 for input the output this form 4 5 6 7 8 9 in c++ language
9 Answers
+ 5
Well, if the first line always had one number in it, and the second line one more... then you could keep track of the number of numbers you have outputted to each line. In line one, after your number count equals one, you make a new line, and so on.
There is probably a more efficient way to do this, but I don't know if it could take an input of any size in it. I hope this makes sense, and the best of luck to you!
+ 5
void numbers(int a, int b)
{
int line = 1, count=0;
for(int i=a; i<=b; ++i )
{ cout <<i <<" ";
count++;
if (line ==count)
{
cout<<endl;
line++;
count=0;
}
}
}
Try something like this đ
Edit: count=0
+ 5
@Robobrine
That works but it outputs:
1
2.3
4.5.6
7.8.9.10
11.12.13.14.15
+ 4
void numbers(int a, int b){
for(int i = a, t = 0, m = 1; i <= b; i++, t--){
cout << i << " ";
if(!t){
cout << endl;
t = ++m;
}
}
}
+ 2
thanks for allđ
+ 1
Wait, what would happen if the user enters 4 and 7?
4
5 6
7
or something else?
+ 1
yes,the output is this form
4
5 6
7
+ 1
i write this answer
#include <iostream>
using namespace std;
void numbers (int,int);
int main() {
int a,b;
cout <<"enter 2 numbers"<<endl;
cin>>a>>b;
numbers (a,b);
return 0;
}
void numbers(int a,int b)
{
for(int i=a;i<=b;i++)
cout<<i<<endl;
}
but not work
0
Hey if you need them all Multipled then hear 4x9=36
36x56=2016
2016=789=159,062,4