A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C++ to print the Floyd's Triangle
Q:

Write a program in C++ to print the Floyd's Triangle

0

Write a program in C++ to print the Floyd's Triangle

Sample Output:

 Print the Floyd's Triangle:                                           
--------------------------------                                       
 Input number of rows: 5                                               
1                                                                      
01                                                                     
101                                                                    
0101                                                                   
10101

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
using namespace std;

int main()
{
   int i,j,n,p,q;
    cout << "\n\n Print the Floyd's Triangle:\n";
    cout << "--------------------------------\n";
    cout << " Input number of rows: ";
    cin >> n;
   for(i=1;i<=n;i++)
   {
     if(i%2==0)
     { 
	 p=1;q=0;
	 }
     else
     { 
	 p=0;q=1;
	 }
      for(j=1;j<=i;j++)
	 if(j%2==0)
	    cout<<p;
	 else
	    cout<<q;
     cout<<endl;
   }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now