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

DIFFRENCE BETWEEN JAVA AND C++

Java Programming JAVA :- 1. Java is true Object oriented language. 2. Java does not support operator overloading. 3. It supports labels with loops and statement blocks . 4. Java does not have template classes as in C++. 5. Java compiled into byte code for the Java Virtual Machine. The source code is independent   on operating system. 6. Java does not support multiple inheritance of classes but it supports interface. 7. Runs in a protected virtual machine. 8 . Java does not support global variable. Every variable should declare in class. 9.  Java does not use pointer. 10. It Strictly enforces an object oriented Programming paradigm. C++ :- 1. C++ is basically C with Object-oriented extension. 2. C++ supports operator overloading. 3. It supports go to statement. 4. C++ has template classes. 5. Source code can be written to be platform independent C++ typically compiled into machine code. 6. C++ supports multiple inheritance ...

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.  

Native code

Java Programming Native code: Native code is computer programming (code) that is compiled to run with a particular processor (such as an Intel x86-class processor) and its set of instructions. If the same program is run on a computer with a different processor, software can be provided so that the computer emulates the original processor. The method is implemented in "native" code. That is, code that does not run in the JVM. It's typically written in C or C++. Native methods are usually used to interface with system calls or libraries written in other programming languages.