Skip to main content

Printing of Stars in a pattern.

→ A simple Java program to print * in a pattern.

class Star
{
public static void main(String args[])
{
int i,j;
for(i=0;i<5;i++)
{
for(j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}

Output:
*
**
***
****
*****

Comments

Popular posts from this blog

A simple calculator program.

→ A simple calculator using C language. In this, you can add, multiply, divide and subtract any two number. #include<stdio.h> int main() {    float a,b,c;    char d;    printf("Enter:");    scanf("%f  %c %f",&a,&d,&b);    if(d=='+')    {     c=a+b;     printf("%.2f",c);    }    else if(d=='-')    {     c=a-b;     printf("%.2f",c);    }    else if(d=='*')    {     c=a*b;     printf("%.2f",c);    }    else if(d=='/')    {     c=a/b;     printf("%.2f",c);    } } Output: Enter:  9/4              2.25