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