0% found this document useful (0 votes)
40 views3 pages

Pattern Series

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Pattern Series

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Different Pattern Series Comparison in C and Java

Pattern-1:-
R/ 0 1 2 3 4
C
0 * * * * *
1 * * * * *
2 * * * * *
3 * * * * *
4 * * * * *

Algorithm:-
Step-1:-Initiate the rows and columns and an integer n, so that no. of rows
and no. of columns can be changed easily.

Step-2:-the logic behind the above pattern is that in all rows and all
columns * is present.

Step-3:-Use two for loops (one inside the other), so that we can print the
above series.

Program in C:-
#include <stdio.h>
int main()
{
int i, j, n=5;
for(i = 0; i < n; i++){
for(j = 0; j < n; j++){
printf("*");
Different Pattern Series Comparison in C and Java

}
printf("\n");
}
}
/*Save it as pattern1.c*/
Program in Java:-
class Demo
{
public static void main(String[] args) {
int n=5;
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
System.out.print("*");
}
System.out.println(" ");
}
}
}
/*Save it as Demo.java*/
/* always save as class name*/
Different Pattern Series Comparison in C and Java

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy