This is a C++ program that prompts the user to input a value, and then prints a square pattern of asterisks with side length equal to the input value. Here is a brief explanation of the program:
#include<iostream> using namespace std; int main() { int i,n,a; cout<<"\nEnter the value:"; cin>>a; for(i=1;i<=a;i++) { cout<<"\n"; for(n=1;n<=a;n++) { cout<<" *"; } } return 0; }To download raw file Click Here
Enter the value:10 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This is a C++ program that prompts the user to input a value, and then prints a triangle pattern of asterisks with base length equal to the input value. Here is a brief explanation of the program:
#include<iostream> using namespace std; int main() { int i,n,a; cout<<"\nEnter the value:"; cin>>a; for(i=1;i<=a;i++) { cout<<"\n"; for(n=0;n<i;n++) { cout<<" "; } for(n=0;n<=(a-i);n++) { cout<<" *"; } } }To download raw file Click Here
Enter the value : 10
  * * * * * * * * * *
   * * * * * * * * *
    * * * * * * * *
     * * * * * * *
      * * * * * *
       * * * * *
        * * * *
         * * *
          * *
           *
This is a C++ program to print a pyramid of asterisks (*) with each row having one more asterisk than the previous row.
The program prompts the user to enter a value, which represents the number of rows in the pyramid. The for loop then iterates from 1 to a, with each iteration representing a row in the pyramid.
Within each row, the program first prints a number of spaces equal to the row number (i), to align the asterisks in the center of the pyramid. It then prints a number of asterisks equal to (a-i+1) to create the pyramid shape.
#include<iostream> using namespace std; int main() { int i,n,a; cout<<"\nEnter the value:"; cin>>a; for(i=1;i<=a;i++) { cout<<"\n"; for(n=0;n<i;n++) { cout<<" "; } for(n=0;n<=(a-i);n++) { cout<<" *"; } } }To download raw file Click Here
Enter the value:10
          *
         * *
        * * *
       * * * *
      * * * * *
     * * * * * *
    * * * * * * *
   * * * * * * * *
  * * * * * * * * *
 * * * * * * * * * *
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions