🔒 Closed Patulong po di pa kasi naturo

Status
Not open for further replies.

Anthony_111

Enthusiast
Salamat po . Yung ituturo niyo aarlin ko din . salamat po
 

Attachments

  • IMG_20210202_152213.webp
    IMG_20210202_152213.webp
    334.8 KB · Views: 34
  • IMG_20210202_152128.webp
    IMG_20210202_152128.webp
    243.7 KB · Views: 28
  • IMG_20210202_152104.webp
    IMG_20210202_152104.webp
    211 KB · Views: 23
  • IMG_20210202_152118.webp
    IMG_20210202_152118.webp
    102.1 KB · Views: 24
  • IMG_20210202_151953.webp
    IMG_20210202_151953.webp
    205.8 KB · Views: 24
  • IMG_20210202_152051.webp
    IMG_20210202_152051.webp
    234.7 KB · Views: 28
Activity 2 - You do not have permission to view the full content of this post. Log in or register now.
[CODE lang="java" title="Act2"] public static void printStars(int n)
{
int i, j;

// outer loop to handle number of rows
// n in this case
for(i=0; i<n; i++)
{

// inner loop to handle number of columns
// values changing acc. to outer loop
for(j=0; j<=i; j++)
{
// printing stars
System.out.print("* ");
}

// ending line after each row
System.out.println();
}
}[/CODE]

Acitvity 3 - You do not have permission to view the full content of this post. Log in or register now.
[CODE lang="java" title="Act3"] static void solidSquare(int rows)
{
int i, j;
for (i = 1; i <= rows; i++)
{
// Print stars after spaces
for (j = 1; j <= rows; j++)
System.out.print("*");

// Move to the next line/row
System.out.print("\n");
}

} [/CODE]

Activity 4 -
[CODE lang="java" title="Act5"]static void act5(int[] arr, int multi){
for(int i = 0; i < arr.length(); i++)
System.out.print(arr * multi + " ");
}[/CODE]
Activity 5 - You do not have permission to view the full content of this post. Log in or register now.
[CODE lang="java" title="Act4"]import java.io.*;

class GFG {
public int factorial(int i)
{
if (i == 0)
return 1;
return i * factorial(i - 1);
}
public static void main(String[] args)
{
int n = 4, i, j;
GFG g = new GFG();
for (i = 0; i <= n; i++) {
for (j = 0; j <= n - i; j++) {
System.out.print(" "); // for left spacing
}
for (j = 0; j <= i; j++) {
// nCr formula
System.out.print(
" "
+ g.factorial(i)
/ (g.factorial(i - j)
* g.factorial(j)));
}
System.out.println(); // for newline
}
}
}[/CODE]

Activity 1 - You do not have permission to view the full content of this post. Log in or register now.
[CODE lang="java" title="Act1"]public static void printNums(int n)
{
int i, j,num;

// outer loop to handle number of rows
// n in this case
for(i=0; i<n; i++)
{
// initialising starting number
num=1;

// inner loop to handle number of columns
// values changing acc. to outer loop
for(j=0; j<=i; j++)
{
// printing num with a space
System.out.print(num+ " ");

//incrementing value of num
num++;
}

// ending line after each row
System.out.println();
}
}[/CODE]
Activity 6
[CODE lang="java" title="Act6"]static void sumArray(int[] arr){
int sum = 0;
for(int i = 0; i < arr.length(); i++)
sum += arr;
System.out.println("Sum: " + sum);
}[/CODE]
 
[XX='Anthony_111, c: 741996, m: 841133'][/XX] naka method type po yan ts, ikaw ang bahala kung gusto mo ganyan na o baguhin mo pa.
 
Status
Not open for further replies.

About this Thread

  • 5
    Replies
  • 291
    Views
  • 2
    Participants
Last reply from:
Anthony_111

Online now

Members online
1,121
Guests online
909
Total visitors
2,030

Forum statistics

Threads
2,277,013
Posts
28,973,733
Members
1,229,686
Latest member
rubellemax1998
Back
Top