Monday, September 3, 2018

Pattern Code - Part 1 - printing all numbers

// Program to print Pattern - Number Pattern in Lines
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines to print
cout<<"Enter Number "; cin>>num;
int r,c;
for( r=1; r<=num; r++)// Outer Loop to print lines - Vertical Count
{
for( c=1 ; c<=num; c++)// Inner Loop for Horizontal Count
{
cout<<c<<" "; // will print Number in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

No comments:

Post a Comment