Thursday, September 23, 2021
Pattern- 8 Star Print
Pattern- 8 Star Print
Logic-
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(" ");
}
{
for(int k=i; k<=5; k++)
System.out.print("* ");
}
System.out.println( );
}
Program--
* * * * *
* * * *
* * *
* *
*
class Pattern8
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=2; j<=i; j++)
{
System.out.print(" ");
}
{
for(int k=i; k<=5; k++)
System.out.print("* ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Pattern- 7 star Print Decrement
Pattern- 7 star Print
Logic-
for(int i=1; i<=5; i++)
{
for(int j=i; j<=5; j++)
{
System.out.print("* ");
}
System.out.println( );
}
Program-
* * * * *
* * * *
* * *
* *
*
class Pattern7
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=i; j<=5; j++)
{
System.out.print("* ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Pattern- 6 Star Print Increment order
Pattern- 6 Star Print
Logic -
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print("* ");
}
System.out.println( );
}
Program-
*
* *
* * *
* * * *
* * * * *
class Pattern6
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=i; j++)
{
System.out.print("* ");
}
System.out.println( );
}
}
}
Saturday, September 18, 2021
Pattern -5 Number print 1 to 25
Pattern -5
Logic---
int k=1;
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; ++j)
{
System.out.print(k++ + " ");
}
System.out.println( );
}
Program---
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
class Pattern5
{
public static void main(String[] args)
{
int k=1;
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; ++j)
{
System.out.print(k++ + " ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Pattern -4 number print 1 0 1 0 1
Pattern -4
Logic---
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
if(j%2==0)
{
System.out.print("0 ");
}
else
System.out.print("1 ");
}
System.out.println( );
}
Program--
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
1 0 1 0 1
class Pattern4
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
if(j%2==0)
{
System.out.print("0 ");
}
else
System.out.print("1 ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Pattern -3 Number print 1 1 1 1 1
Pattern -3
Logic--
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print(i);
}
System.out.println( );
}
Program--
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
class Pattern3
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print(i);
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Pattern - 2 Number 1 to 5
Pattern - 2
Logic--
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print(j);
}
System.out.println( );
}
Program-
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
class Pattern2
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print(j);
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Friday, September 17, 2021
Pattern-1 Star Print
Pattern1-
Star Pattern CodeWithVed
Logic--
Program:-
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
class Pattern1
{
public static void main(String[] args)
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
System.out.print("* ");
}
System.out.println( );
}
}
}
For Proper Understanding Watch the Video :-
Thursday, September 16, 2021
Magic Number in Java
Program to Check If a Number is Magic number or not
Steps--
Program :-
class Magic
{
public static void main(String[] args)
{
System.out.println("Enter the value");
int n1=new java.util.Scanner(System.in).nextInt();
int num, rem=1, sum=0;
num=n1;
while (num>9)
{
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
num=sum;
sum=0;
}
if (num==1)
{
System.out.println(n1 + " is a Magic number ");
}
else
{
System.out.println(n1 + " is a not Magic number");
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Wednesday, September 15, 2021
Harshad Number
Program to Check If a Number is Harshad number or not.
Harshad Number CodeWithVed
Steps:-
Program:-
// Java Program to Check If a Number is Harshad number or not.
class Harshad
{
public static void main(String[] args)
{
System.out.println("Enter the value");
int n1=new java.util.Scanner(System.in).nextInt();
int num, rem=0, sum=0;
num=n1;
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
if(n1%sum==0)
{
System.out.println(n1 + " is a Harshad number ");
}
else
{
System.out.println(n1 + " is a not Harshad number");
}
}
}
For Proper Understanding Watch the Video :-
Buzz Number
Program to Check If a Number is Buzz number or not
![]() |
Buzz Number CodeWithVed |
Steps:-
Program:-
class Buzz
{
public static void main(String[] args)
{
System.out.println("Enter the value");
int n1=new java.util.Scanner(System.in).nextInt();
int num;
num=n1;
if (num % 10 == 7 || num % 7 == 0)
{
System.out.println(n1 + " is a Buzz number ");
}
else
{
System.out.println(n1 + " is a not Buzz number");
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Subscribe to:
Posts (Atom)
-
Pattern -4 Logic--- for(int i=1; i<=5; i++) { for(int j=1; j<=5; j++) ...