Skip to content

Commit fc5403e

Browse files
committed
Basic Programs
1 parent e0301e0 commit fc5403e

14 files changed

+70
-70
lines changed

InterviewPrograms/src/com/java/basic/AddWithoutPlus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* Add two numbers a,b without using + operator
5-
*
5+
* --------------------------------------------
66
* Use bitwise operators instead of using + operator
77
* bitwise and = &
88
* XOR operator = ^

InterviewPrograms/src/com/java/basic/DigitsOfNumber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import java.util.Scanner;
55

66
/*
7-
* Digits of a Given Number
8-
*
7+
* Digits of a Given Number
8+
* -------------------------
99
* For any positive number print the digits
1010
* of the number.
1111
*

InterviewPrograms/src/com/java/basic/Divisors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import java.util.TreeSet;
55

66
/*
7-
* Divisors of N
8-
*
7+
* Divisors of N
8+
* -------------
9+
*
910
* This program finds all the divisors of the
1011
* Given number N
1112
*
@@ -18,7 +19,6 @@
1819
*/
1920

2021
public class Divisors {
21-
2222
public static void main(String[] args) {
2323
Scanner scanner = new Scanner(System.in);
2424
System.out.println("Enter the N value : ");

InterviewPrograms/src/com/java/basic/EvenOrOdd.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import java.util.Scanner;
44

55
/*
6-
* EVEN OR ODD
7-
*
8-
* Divide the given number by 2
9-
* If the reminder is 0 then its EVEN
10-
* If the reminder is 1 then its ODD
6+
* EVEN OR ODD
7+
* ------------
8+
* Divide the given number by 2
9+
* If the reminder is 0 then its EVEN
10+
* If the reminder is 1 then its ODD
1111
*
12-
* 22 EVEN number
13-
* 23 ODD number
12+
* 22 EVEN number
13+
* 23 ODD number
1414
*
1515
*/
1616
public class EvenOrOdd {

InterviewPrograms/src/com/java/basic/Factorial.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Scanner;
44

55
/*
6-
* Factorial
7-
*
6+
* Factorial
7+
* ----------
88
* In mathematics, the factorial of a positive integer n,
99
* denoted by n!, is the product of all positive integers
1010
* less than or equal to n:
@@ -31,8 +31,8 @@ public static void main(String[] args) {
3131
for(int i=1; i<=N; i++)
3232
result = result * i;
3333

34-
String output = String.format("Factorial of %d is %d", N,result);
35-
System.out.println(output);
34+
System.out.print("Factorial of "+N);
35+
System.out.print(" is "+result);
3636
scanner.close();
3737
}
3838
}

InterviewPrograms/src/com/java/basic/FactorialUsingRecursion.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Scanner;
44

55
/*
6-
* Factorial Using Recursion
7-
*
6+
* Factorial Using Recursion
7+
* --------------------------
88
* In mathematics, the factorial of a positive integer n,
99
* denoted by n!, is the product of all positive integers
1010
* less than or equal to n:

InterviewPrograms/src/com/java/basic/FactorsOfANumber.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import java.util.Scanner;
44

55
/*
6-
* Factors of a Given Number
6+
* Factors of a Given Number
7+
* --------------------------
78
*
89
* A number which divides the given number and gives
910
* reminder as zero, then that number is called as Factor.
@@ -13,9 +14,9 @@
1314
*
1415
* say Given number is 40, factors are
1516
* 1, 2, 4, 5, 8, 10, 20, 40
17+
*
1618
*/
1719
public class FactorsOfANumber {
18-
1920
public static void main(String[] args) {
2021
Scanner scanner = new Scanner(System.in);
2122
System.out.println("Enter any positive integer :: ");

InterviewPrograms/src/com/java/basic/FindTheSmallest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.java.basic;
22
/*
33
* Find the Smallest of 3 (a,b,c) without using < or > symbol
4-
*
4+
* ----------------------------------------------------------
55
* Mostly to find max or min we use < or > symbol
66
* But here without using < or > symbol how to find smallest
77
*

InterviewPrograms/src/com/java/basic/LeapYear.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import java.util.Scanner;
44

55
/*
6-
* LEAP YEAR
7-
* This program is to check the given number is leap year or not.
6+
* LEAP YEAR
7+
* ---------
8+
* This program is to check the given number is leap year or not.
89
*
9-
* Leap Year Conditions
10+
* Leap Year Conditions
1011
* 1. Year should be divisible by 4
1112
* 2. If it is divisible by 100 then should be divisible by 400
1213
* 3. If both conditions are not satisfied, then given input is not leap year.

InterviewPrograms/src/com/java/basic/PositiveOrNegative.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import java.util.Scanner;
44

55
/*
6-
* Positive Or Negative
7-
*
8-
* An integer is a whole number that can be either
9-
* greater than 0, called positive, or less than 0,
10-
* called negative.
6+
* Positive Or Negative
7+
* ---------------------
8+
* An integer is a whole number that can be either
9+
* greater than 0, called positive, or less than 0,
10+
* called negative.
1111
*
1212
* Zero is neither positive nor negative.
1313
*
14-
* 100 is Positive Number
15-
* -22 is Negative Number
14+
* 100 is Positive Number
15+
* -22 is Negative Number
1616
*
1717
*/
1818
public class PositiveOrNegative {

0 commit comments

Comments
 (0)