C++ Star Triangle Program Example


Example C++ program to create a triangle of numbers. This time the admin will discuss how to make a star image using for. This is basic programming that must be mastered by friends who want to deepen their programming language, one of which is by mastering the language C++. java, php, python And many others.

So, let’s go straight to how to make a star image in C++ programming. Before that I used CodeBlock To create or execute the C++ language. If you already have or have installed the application, we continue.

However, if you still don’t have the application, please download it via INI. If you want to download it via the original website, please click THIS. ok next, How to make a triangle in C++ language.

Here’s how;

Just go this way.

This is an example of a star creation script using C++. Here you can simply use For and play China and Count

Script

Copy the Scipt below and paste it in the codeblock or application you are using

#include

using namespace std;

int main()
{
int t;
cout << "Enter the number to make a star :";
cin >>t;
for (int a=1; a<=t; a++){
for (int b=a; b<=t; b++) cout<<" ";
for (int b=1; b<=a; b++) cout<<“*”;
for (int b=1; b<=a; b++) cout<<“*”;
cout<}
for (int a=1; a<=t; a++){
for (int b=1; b<=a; b++) cout<<" ";
for (int b=a; b<=t; b++) cout<<“*”;
for (int b=a; b<=t; b++) cout<<“*”;
cout<}
cout<returns 0;
}

this is the result of the above script. see image below. here using Cin and Cout because later you can adjust how many stars you want to Cout as in the image below Admin uses 5 numbers and the result is 5 numbers.

This means that the 5 numbers are 5 rows from the top and 5 rows down.

www.pencariilmu.com

Well that’s an example C++ programming takes three hundred digits good luck and greetings admin


Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *