Thursday, 3 December 2020

Write a Program in C++ to Print the Floyd's Triangle

 /*

 Floyd's Triangle:

 1

 2 3

 4 5 6

 7 8 9 10

 11 12 13 14 15

 */

 #include<iostream>

 using namespace std;

 int main()

 {

   int i,j,p;

   for(i=1,p=1;i<=5;i++)

   {

       for(j=1;j<=i;j++)

       {

       cout<<p<<" ";

       p++;

       }

       cout<<endl;

   }

 }

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...