Thursday, January 22, 2015

c++ create right triangle.

this is how to create right triangle on c++.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {

int a;
cout<<"Enter N:";
cin>>a;
for(int x= 1;x<=a;x++) {
for(int y=1;y<=x;y++) {
cout<<"*";
}
cout<<"\n";
}
cin.get();
cin.get();
return 0;
}













#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {

int a;
cout<<"Enter N:";
cin>>a;
for(int x= 1;x<=a;a--) {
for(int y=1;y<=a;y++) {
cout<<"*";
}
cout<<"\n";
}
cin.get();
cin.get();
return 0;
}


No comments:

Post a Comment

Designed By Seo Blogger Templates Published.. Blogger Templates