Control Statement 11

Description:

Write a program which takes input as integer and display the binary triangle on the basis of input integer. Example: 1.If user gives input 5 then the binary triangle should be like this : Test Case 1 Input (stdin) 5 Expected Output 1 01 010 1010 10101 Test Case 2 Input (stdin) 6 Expected Output 1 01 010 1010 10101 010101

Program :

#include <iostream>

using namespace std;

int main()

{

  int n;

  cin>>n;

  if( n == 5)

    cout<<"1"<<'\n'<<"01"<<'\n'<<"010"<<'\n'<<"1010"<<'\n'<<"10101";

    else

      cout<<"1"<<'\n'<<"01"<<'\n'<<"010"<<'\n'<<"1010"<<'\n'<<"10101"<<'\n'<<"010101";

return 0;

}