Tuesday, 22 November 2016

Write a program that inputs the height of a triangle and display it using loop.


Write a program that inputs the height of a triangle and display it using loop. For example if the user enters height as 5, the program should display the following. 



         #include <iostream.h>
        #include <conio.h>
        int main ()

        {
               int i , n , j;
              
               cout<< "Please Give the value of N as height: " ;
               cin>> n;

                for (i = n; i > 0; i++)
               {
                   for (j = n-i; j > 0; j--)
                   cout<<" ";

                   for (j = 2 i-1; j > 0; j--)
                   cout<<"&";

                 cout<<"\n";
               }

               return 0;
        }    
     

Output: 


2 comments:

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...