0% found this document useful (0 votes)
8 views

Assignment 5

Uploaded by

megh94001
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment 5

Uploaded by

megh94001
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name-Megh Patel

Div-b
Sub-spm

Assignment : 5

Q:1

public class Neer5


{
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("");
}
}
}

run:
*
**
***
****
*****
BUILD SUCCESSFUL (total time: 0 seconds)

Q:2

public class Neer6


{
public static void main(String args[])
{
for(int i=1;i<=5;i++)
{
for(int j=i;j<=5;j++)
{
System.out.print(" ");
}
for(int j=1;j<=i;j++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
Name-Megh Patel
Div-b
Sub-spm

run:
*
**
***
****
*****
BUILD SUCCESSFUL (total time: 0 seconds)

Q:3

public class Neer7


{
public static void main(String args[])
{
for(int i=1;i<=5;i++)
{
for(int j=1;j<=5;j++)
{
if(i==1 || i==5 || j==1 ||j==5){
System.out.print("@");
}
else
System.out.print(" ");
}
System.out.println(" ");
}
}
}

run:
@@@@@
@ @
@ @
@ @
@@@@@
BUILD SUCCESSFUL (total time: 0 seconds)

Q:4

import java.util.Scanner;
public class Neer8
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
Name-Megh Patel
Div-b
Sub-spm

int n;
System.out.println("enter the n");
n=sc.nextInt();
for(int i=1;i<=5;i++)
{
for(int j=1;j<i;j++)
{
System.out.print(j);
}
System.out.println("");
}
}
}

run:
enter the n
1

1
12
123
1234
12345
BUILD SUCCESSFUL (total time: 1 second)

Q:5

import java.util.Scanner;
public class Neer9
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n;
System.out.println("enter the n");
n=sc.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=n;j>=i;j--){
System.out.print(j);

}
System.out.println("");
}
}
}
Name-Megh Patel
Div-b
Sub-spm

run:
enter the n
7
7654321
765432
76543
7654
765
76
7
BUILD SUCCESSFUL (total time: 1 second)

Q:6

public class Neer10


{
public static void main(String args[])
{
for(int i=1;i<=5;i++)
{
for(int j=i;j<=5;j++)
{
System.out.print(" ");
}
for(int j=1;j<=7;j++)
{
System.out.print("*");
}
System.out.println("");
}
}
}

run:
*******
*******
*******
*******
*******
BUILD SUCCESSFUL (total time: 0 seconds)

You might also like