Tuesday, September 4, 2018

printing alphabets in a grid pattern (1 to r) pattern program

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

Pattern printing number patterns part -2 Program 3

// Program to print Pattern 2
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines
cout<<"Enter Number "; cin>>num;
for(int r=1; r<=num; r++) {
for(int c=1; c<=num-r+1; c++) // Inner Loop
// will run from 1 to num - r +1
//(value from outer loop)
// so with every line star will reduce
{
cout<<r<<" "; // will print col num in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

Printing Star pattern -2 Program

// Program to print Pattern - Triangle of stars
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines
cout<<"Enter Number "; cin>>num;
for(int r=1; r<=num; r++) {
for(int c=1; c<=num-r+1; c++) // Inner Loop
// will run from 1 to num - r+1
//(value from outer loop)
// so with every line star will reduce
{
cout<<"*"; // will print * in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

Monday, September 3, 2018

Patterns using Nested Loop part -1 | Nested Loops in C++ | Draw star patt...

NESTED LOOP PATTERN PART -1 - ALL STARS

// Program to print Pattern - square of Stars
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int num; // To input number of lines to print
cout<<"Enter Number "; cin>>num;
char ch; cout<<"Enter Character "; cin>>ch;
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<<ch; // will print * in a single line
}
cout<<"\n"; // At end of inner loop next line will
// come in a new line
}
getch();
}

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();
}

Tuesday, January 30, 2018

VERY VERY HELPFUL XI CS VIVA QUESTIONS

Viva General by chandni1972 on Scribd