Example of for loop in c++ programing
All Contributions
Example of How to Write a program to Program to print half pyramid using alphabets:
#include <iostream>
using namespace std;
int main()
{
char input, alphabet = 'A';
cout << "Enter the uppercase character you want to print in the last row: ";
cin >> input;
for(int i = 1; i <= (input-'A'+1); ++i)
{
for(int j = 1; j <= i; ++j)
{
cout << alphabet << " ";
}
++alphabet;
cout << endl;
}
return 0;
}
How to Write a program that prints even numbers from 0 to 100:
#include
using namespace std;
int main()
{
for (int i = 0 ; i <= 100; i++)
{
if ( i % 2 ==0)
{
cout << i << endl;
}
return 0 ;
}
Example of How to Write a program to Program to print half pyramid using alphabets:
#include <iostream>
using namespace std;
int main()
{
char input, alphabet = 'A';
cout << "Enter the uppercase character you want to print in the last row: ";
cin >> input;
for(int i = 1; i <= (input-'A'+1); ++i)
{
for(int j = 1; j <= i; ++j)
{
cout << alphabet << " ";
}
++alphabet;
cout << endl;
}
return 0;
}
Example of How to Write a program to Program to print half pyramid using alphabets:
#include <iostream>
using namespace std;
int main()
{
char input, alphabet = 'A';
cout << "Enter the uppercase character you want to print in the last row: ";
cin >> input;
for(int i = 1; i <= (input-'A'+1); ++i)
{
for(int j = 1; j <= i; ++j)
{
cout << alphabet << " ";
}
++alphabet;
cout << endl;
}
return 0;
}
total contributions (8)
Example of how to Write a program Print Pascal's triangle :