in this we have to show table of 50 to 150
like 50 table from 1 to 10
then 51 table ......150 table
i just want to know is there any way i can get this using loop not using nested loop
i made the nested loop code to show you what i want on ouput
You must be using an old or out of date compiler. To be standard-compliant, the include file you want is <iostream>, not <iostream.h>, and you will need to use std::cout and std::endl (or usingnamespace std;). Also, main() must return an int, not void.
Anyway, you do not have a nested loop. You have 2 loops running concurrently. A nested loop would be:
If you're dead set on not using nested loops, then you could probably kludge it with some fiddly maths and a bunch of if statements. But why would you bother? Using nested loops is much simpler and cleaner.
#include <iostream>
#include <iomanip>
int main()
{
for ( int n = 1, i = 50; i <= 150; i += n / 10, n = n % 10 + 1 )
{
std::cout << std::setw( 3 ) << i << " * "
<< std::setw( 2 ) << n << " = "
<< std::setw( 4 ) << i * n << std::endl;
}
}