JavaScript is not enabled on your browser and in order to properly use Coder Profile JavaScript is required.
To view instructions on how to enable JavaScript on your browser click here .
Author Details
Code Information
Language
C++
Expires
Never
Length
524 Characters (14 Lines)
Password
no password
Description
Create a triangle using some variables and a simple for loop: with explanations! :O
//Create-A-Triangle
#include <iostream>
#include <string>
using namespace std;
int main() { //initiates our main function
int numLoops = 25; //our number 'numLoops' equals 25
string a = "@"; //our string 'a' equals "@"
string holder = "@"; //our string 'holder' equals "@"
for (int i(0); i < numLoops; ++i) { //initiates our for loop
cout << holder << endl; //outputs 'holder' and adds new line
holder = holder + a; //adds our value 'a' to 'holder'
} //closes our for loop
} //closes our main function
Please login to post comments.
Haha, nice and simple. Think this would be cool as a source code on your profile with a screenshot and stuff, as opposed to a pinned code (code snippet). Nice work though, and keep up the commenting on your codes ;-)
Kind regards,
Scott
::
::
::
::
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved