0% found this document useful (0 votes)
34 views8 pages

Program 1 12

The document contains 12 C++ programs. Program 1 prints increasing numbers in a triangle pattern. Program 2 is similar but increments the number at the beginning of each row. Program 3 prints the numbers with spaces between. Program 4 adds spacing to the left of each row. Programs 5-7 demonstrate additional patterns using numbers or characters. Programs 8-9 print patterns using symbols like asterisks and at signs. Programs 10-11 count vowels/consonants in a string and print letter patterns respectively. Program 12 demonstrates moving text output on the screen.

Uploaded by

Kervin Echano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views8 pages

Program 1 12

The document contains 12 C++ programs. Program 1 prints increasing numbers in a triangle pattern. Program 2 is similar but increments the number at the beginning of each row. Program 3 prints the numbers with spaces between. Program 4 adds spacing to the left of each row. Programs 5-7 demonstrate additional patterns using numbers or characters. Programs 8-9 print patterns using symbols like asterisks and at signs. Programs 10-11 count vowels/consonants in a string and print letter patterns respectively. Program 12 demonstrates moving text output on the screen.

Uploaded by

Kervin Echano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Program #1

#include <iostream>
using namespace std;
int main()
{
int row;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
for (int column = 0; column < i; column++){
number++;
cout <<number;
}
number = 0;
cout << endl;
}
}

Program #2
#include <iostream>
using namespace std;
int main()
{
int row;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
number++;
for (int column = 0; column < i; column++){
cout <<number;
}
cout << endl;
}
}

Program #3
#include <iostream>
using namespace std;
int main()
{
int row;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){

for (int column = 0; column < i; column++){


number++;
cout <<number<<" ";
}
cout << endl;
}
}

Program #4
#include <iostream>
using namespace std;
int main()
{
int row,space;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
space = row - i;
number++;
while(space !=0){
cout<<" ";
space--;
}

for (int column = 0; column < i; column++){


cout <<number <<" ";
}
cout << endl;
}
}

Program #5
#include <iostream>
using namespace std;
int main()
{
int row;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){

for (int column = 0; column < i; column++){


number++;
cout <<number<<" ";
}
cout << endl;
}
}

Program #6
#include <iostream>
using namespace std;
int main()
{
int row,space;
int number = 0;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
space = row - i;
while(space !=0){
cout<<" ";
space--;
}
for (int column = 0; column < i; column++){
cout <<"* ";
}
cout << endl;
}
for(int i = 1; i <= row; i++){
space = 0;
while(space != i){
cout<<" ";
space++;
}
for (int column = row; column >i; column--){
cout <<"* ";
}
cout << endl;
}
}

Program #7
#include <iostream>
using namespace std;
int main()
{
int row,space,coef ;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 0; i < row; i++){
space = row - i;
while(space !=0){
cout<<" ";
space--;
}

for (int column = 0; column <=i; column++){


if (column == 0 || i == 0){
coef = 1 ;
}
else
coef = coef*(i-column+1)/column;
cout<< coef <<" ";
}
cout << endl;
}
}

Program #8
#include <iostream>
using namespace std;
int main()
{
int row,space;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
space = 0;
while(space != i){
cout<<" ";
space++;
}

for (int column = row; column >=i; column--){


cout <<"* ";
}
cout << endl;
}
}

Program #9
#include <iostream>
using namespace std;
int main()
{
int row,space;
cout << "Input number of rows: ";
cin >> row;
cout <<"Results:" << endl;
for(int i = 1; i <= row; i++){
space = row - i;
while(space >=1){
cout<<" ";
space--;
}
for (int column = 0; column < i; column++){
cout <<"@ ";
}
cout << endl;
}
}

Program #10
#include <iostream>
using namespace std;
int main()
{
char letter[10];
int vctr = 0, cctr = 0;
int x;
cout << "Enter 10 Characters: ";
cin.getline(letter,20);
for(int x = 0; letter[x]!='\0';x++){
if(letter[x]=='a' || letter[x]=='e'|| letter[x]=='i'|| letter[x]=='o' || letter[x]=='u' ||
letter[x]=='A' || letter[x]=='E' || letter[x]=='I' || letter[x]=='O'|| letter[x]=='U')
{
vctr++;
}
else
{
cctr++;
}
}
cout << "Total Vowels: " << vctr << endl;
cout << "Total Consonants: " << cctr << endl;
return 0;
}

Program #11
#include <iostream>
using namespace std;
int main()
{
int row,space;
int rep = 0;
cout << "Input letter of rows: ";
cin >> row;
cout <<"Results:" << endl;
char letter = 65;
for(int i = 1; i <= row; i++){
space = row - i;
while(space !=0){
cout<<" ";
space--;
}
rep = 0;
for (int column = 0; column < i; column++){
letter = 65;
if( column == 0)
cout<<letter;
else{
rep++;
letter +=rep;
cout<<letter;
}
}
for (int column = 1; column < i; column++){
letter -=1;
cout<<letter;
}
cout << endl;
}
rep = 0;
for(int i = 1; i <= row; i++){
space = 0;
while(space != i){
cout<<" ";
space++;
}
rep = 0;
for (int column = row -1; column >= i; column--){
letter = 65;
if( column == row-1)
cout<<letter;
else{
rep++;
letter +=rep;
cout<<letter;
}
}
for (int column = row -1; column > i; column--){
if (rep!=0){
letter -=1;
cout<<letter;
}
rep--;
}
cout << endl;
}

Program #12
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <dos.h>
#include<cstdlib>
#include<ctime>
using namespace std;
void gotoxy(int x, int y) {
COORD c= {x,y};
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE),c);
}
int main()
{
int x;
for(x=0;x<60;x++){
gotoxy(10+x, 12);cout << "Hello world!";
Sleep(100);
gotoxy(9+x, 12);cout << " ";
}
return 0;
}

You might also like