Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Java/program-1/program.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public static void main (String[] args) {
int arr[]=new int[N];
System.out.println("Enter the elements in the array");
for(int i=0;i<N;i++)
{
arr[i]=sc.nextInt();
}
int min=arr[0]; // Assuming first element to be the minimum
int max=arr[0]; // Assuming first element to be the maximum
for(int i=1;i<N;i++)
Expand All @@ -21,4 +23,4 @@ public static void main (String[] args) {
}
System.out.println("Minimum="+min+"\nMaximum="+max);
}
}
}
36 changes: 36 additions & 0 deletions Java/program-14/program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Java program to convert a decimal
// number to binary number
import java.io.*;

class GFG
{
// function to convert decimal to binary
static void decToBinary(int n)
{
// array to store binary number
int[] binaryNum = new int[1000];

// counter for binary array
int i = 0;
while (n > 0)
{
// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}

// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
System.out.print(binaryNum[j]);
}

// driver program
public static void main (String[] args)
{
int n = 17;
decToBinary(n);
}
}

// Contributed by Pramod Kumar
14 changes: 14 additions & 0 deletions Java/program-14/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Q Java Program for Decimal to Binary Conversion

Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number.

Examples:

Input : 7
Output : 111

Input : 10
Output : 1010

Input: 33
Output: 100001
36 changes: 36 additions & 0 deletions Java/program-15/program.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Java program to convert a decimal
// number to binary number
import java.io.*;

class GFG
{
// function to convert decimal to binary
static void decToBinary(int n)
{
// array to store binary number
int[] binaryNum = new int[1000];

// counter for binary array
int i = 0;
while (n > 0)
{
// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}

// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
System.out.print(binaryNum[j]);
}

// driver program
public static void main (String[] args)
{
int n = 17;
decToBinary(n);
}
}

// Contributed by Pramod Kumar
14 changes: 14 additions & 0 deletions Java/program-15/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Q Java Program for Decimal to Binary Conversion

Given a decimal number as input, we need to write a program to convert the given decimal number into equivalent binary number.

Examples:

Input : 7
Output : 111

Input : 10
Output : 1010

Input: 33
Output: 100001