Friday , February 23 2018
Home / Pattern Making

Pattern Making

c program for pattern#12

Pattern#12 1 12 123 1234 This pattern is also an easy one , where you have to indent each line accordingly. Here you can observe that the indentation is directly related to the numbers in each row. If no. of lines are n . then for ith row output is= (n-i)Blank spaces + (1 to i) numbers  Also check: Alternate Java ...

Read More »

c program for pattern#14

Pattern #14 1 01 101 0101 10101 This is a tricky pattern where you have to reduce your coding otherwise it easy using if statement . Can you do it without if statement? Also see: Alternate Java program for pattern#14 #include<stdio.h> void main() { int i,j,calc; for(i=1;i<=5;i++) { for(j=0;j<i;j++) { calc=(i+j)%2; printf("%d",calc); } printf("\n"); } } OUTPUT:

Read More »

c program for pattern#6

Pattern#6 * *** ***** ******* ********* Also see : Alternate Java program for pattern#6 #include<stdio.h> int main() { int n,i,j; // initialize the variables printf("Enter the number of rows in the pattern : "); scanf("%d",&n); // number of rows to be printed. for(i=1;i<=n;i++) // loop for number of rows in pyramid { for(j=1;j<=n-i;j++) // loop for spaces printf(" "); // ...

Read More »

c program for Star Pattern

c program for Star Pattern * *** ***** ******* ********* Also see : Alternate Java program for pattern#6 #include<stdio.h> int main() { int n,i,j; // initialize the variables printf("Enter the number of rows in the pattern : "); scanf("%d",&n); // number of rows to be printed. for(i=1;i<=n;i++) // loop for number of rows in pyramid { for(j=1;j<=n-i;j++) // loop for ...

Read More »

java program for pattern #14

1 01 101 0101 10101 This is an easy to implement pattern but the quality of a programmer depends on the way they implement their algorithm. How much can you reduce your coding. So here is how you can code this pattern without using if statement. Also see: Alternate c program for pattern#14 class pattern { public static void main(String ...

Read More »

c program for pattern13

 C program for pattern making        1      21   321 4321 Here is given c program for following pattern. In the above pattern we have two triangle one is empty space triangle together with the shown triangle. That’s why we have to put the loop for empty spaces together with the loop for the shown triangle. ...

Read More »

Java program for Floyds Triangle

Floyds triangle

Java program for Floyds Triangle: Floyd’s Triangle is one of the most popular pattern in programming lanuguage. It is not usually famous by its name as it is very easy in implementation. The diagram below shows you the floyds triangle: // Java program for Floyd's triangle import java.util.*; class floyd { public static void main(String args[]) { int i,j,n,k=1; Scanner ...

Read More »

Java program for string in circular fashion.

Write a program to input any string and output it in the following format:  hello elloh llohe lohel ohell   class circularstring { public static void main(String args[]) { String str=args[0],p,s=""; int i,j; for(i=0;i<str.length();i++) { p=str.substring(i,l); s=str.substring(0,i); System.out.println(p+s); } } } OUTPUT:   hello elloh llohe lohel ohell Tags: java program for circular string, bluej program for circulating the string ...

Read More »

java program for pattern#6

Java program for printing the following pattern: * *** ***** ******* This program also have indentation. Indentation required depends on the output needed and here indentation requires is: for row 1:  total 4 spaces and then 1 start row 2: total 3 spaces and 3 stars row 3: total 5 spaces and 5 stars……. So on  So here spacing is ...

Read More »

java program for pattern#12

Java program for pattern with indentation or spacing 1 12 123 1234 This is a simple java program for pattern with indentation. Indentation in pattern is thus required. This can be done using extra for loop to provide the required indentation per line. Also Check: Alternate C program for this pattern #12 class format4 { public static void main(String args[]) ...

Read More »