Skip to main content

Pattern Programs in C++


                                                                                                                                                                                  

Pattern 1:-

Example => input  : 4
output :      ****
                    ****

#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;

for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}
                                                                                                                                                                                  

Pattern 2:-

Example => input  : 4
output :   
* * * *
 * * *
 * *
 *

#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}

                                                                                                                                                                 

Pattern 3:-

Example => input  : 4
output :  
 *  
 * *
 * * *
 * * * *

#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=0;j<=i;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}

                                                                                                                                                                                  

Pattern 4:-

Pattern Programe
Example => input  : 3
output :     
     *  
   ***
 *****

#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
for(int j=n-i;j>1;j--){
cout<<"  ";
}
for(int j=0;j<=i;j++){
cout<<"*"<<" ";
}
for(int j=1;j<=i;j++){
cout<<"*"<<" ";
}
cout<<endl;
}
return 0;
}

                                                                                                                                                                 

VERY SOON MORE PROGRAME  WILL BE UPLOAD THERE...


Comments

Popular posts from this blog

Byte Code:

Java Programming Byte Code: It is the unique characteristic property of the Java programming language. It is something like a normal text file. Therefore, it cannot be affected by virus. It is an intermediate between a human readable source and machine readable source. Byte codes are plate form independent. Therefore, JVM is plate form dependent to make Java programming plate form indepdent.  

Difference between Class and Interface

Java Programming   *Difference between Class and Interface                                                  Class 1.  The members of a class can be constant or variables.  2. The class definition can contain code for each of its methods. That is, the methods can be    abstract or non-abstract. 3. It can be instantiated by declaring objects. 4. It can use various access specifier like public,private or protected.                                                Interface     1. The members of an interface are always declared as constant, i.e. their values are final.  2. The methods in an interface are abstract in nature, i.e., there is no code associated with  ...

OPERATING SYSTEM

1.  The term 'operating system'   means: a)  the way a computer operator   works. b)  conversion of high level languages into machine   code. c)  a set of programs which controls computer   working. d)  none of the   above. 2.  What is the name of the operating system that reads and reacts in terms of actual   time: a)   Batch   system b) Time sharing system c) Real   time   system d) all of the above. 3.  The primary job of the operating system of a computer is   to: a)   command   resources b) manage   resources c) be   user friendly d) only one of the   above. 4.  Multiprogramming   systems: a) are easier to develop than single programming systems. b) execute more jobs in same time period. c) are used only on large   mainframe   computers. d) all of the above 5.  Which of the following is not an a...