Showing posts with label Pattern Programming. Show all posts
Showing posts with label Pattern Programming. Show all posts

Monday, 25 February 2019

Pattern 3 44 555 6666 6666 555 44 3

Input:
4

Output:
3
44
555
6666
6666
555
44
3

Source code:
#include<stdio.h>
int main()
{
    int n,i,j,k,s=3;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(k=1;k<=i;k++)
        {
            printf("%d",s);
        }
        s++;
        printf("\n");
    }
    s--;
    for(i=n;i>=1;i--)
    {
        for(k=1;k<=i;k++)
        {
            printf("%d",s);
        }
        s--;
        printf("\n");
    }
    return 0;
}


Saturday, 22 September 2018

1. To Print Butterfly Pattern using loops


Solution:

#include <stdio.h>

int main()

{
    int i,j,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=2*n;j++)
        {
            if(i<j)
            printf(" ");
            else
            printf("&");
            if(i<=2*n-j)
            printf(" ");
            else
            printf("&");
        }
        printf("\n");
    }
        for(i=1;i<=n;i++)
    {
        for(j=1;j<=2*n;j++)
        {
            if(i>(n-j+1))
            printf(" ");
            else
            printf("&");
            if((i+n)>j)
            printf(" ");
            else
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Random password generator in Java

       Random password generator in Java Source code: mport java.io.*; import java.util.*; public class Main { public static void main(Str...