Pyramid Number Pattern in C++
Print the following pattern for the given number of rows.
Pattern for N = 4
Input format : N (Total no. of rows)
Output format : Pattern in N lines
Sample Input :
Sample Output :
C/C++,java,python c++ keywords, identifiers, data types,variables,modifiers,storage classes,operators,for loop ,while loop,do while loop,if else statement,nested loops,break continue goto statement,functions ,call by value call by reference ,arrays ,strings,pointers,data structures ,classes and objects,inheritance,polymorphism,operator overloading,function overloading,data abstraction,data encapsulation,dynamic memory allocation for array and objects,function templates,class templates,
Pyramid Number Pattern in C++
1 212 32123 4321234
Input format : N (Total no. of rows)
Output format : Pattern in N lines
5
1
212
32123
4321234
543212345
C++ Code:
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1; i<=n; i++)
{
for(int j=1; j<n-i+1; j++)
{
cout<<" ";
}
for(int j=i;j<0;j--)
{
cout<<j;
}
cout<<endl;
}
}
0 comments:
Post a Comment