Source Codes

1 Comment

Java program to Find Factorial of Given no.

1 2 3 4 5 6 7 8 9 10 11 class Factorial{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); //take argument as command line int result = 1; while(num>0){ result = result * num; num–; } System.out.println("Factorial of Given no. is : "+result); } }

2 Comments

Java program to find SUM AND PRODUCT of a given Digit.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 class Sum_Product_ofDigit{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); //taking value as command line argument. int temp = num,result=0; //Logic for sum of digit while(temp>0){ result = result + temp; temp–; } […]

No Comments

Java program to generate 5 Random nos. between 1 to 100

1 2 3 4 5 6 7 8 9 10 /*Write a program to generate 5 Random nos. between 1 to 100, and it should not follow with decimal point. */ class RandomDemo{ public static void main(String args[]){ for(int i=1;i<=5;i++){ System.out.println((int)(Math.random()*100)); } } }

No Comments

Java program to print Small Integer, Largest Integer

1 2 3 4 5 6 7 8 9 10 11 12 13 14 /* Write a program that will read a float type value from the keyboard and print the following output. ->Small Integer not less than the number. ->Given Number. ->Largest Integer not greater than the number. */ class ValueFormat{ public static void […]

2 Comments

Java program to find Minimum of 2 nos. using conditional operator

1 2 3 4 5 6 7 8 9 10 class Minof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); int result = (i<j)?i:j; System.out.println(result+" is a minimum value"); } }

No Comments

Java program to find Maximum of 2 nos

1 2 3 4 5 6 7 8 9 10 11 12 class Maxof2{ public static void main(String args[]){ //taking value as command line argument. //Converting String format to Integer value int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]); if(i > j) System.out.println(i+" is greater than "+j); else System.out.println(j+" is greater than "+i); } }

14 Comments

C++ program to implement Heap sort Algorithm

#include <iostream.h> const int MAX = 10 ; class array { private : int arr[MAX] ; int count ; public : array( ) ; void add ( int num ) ; void makeheap(int ) ; void heapsort( ) ; void display( ) ; } ; array :: array( ) { count = 0 ; for […]

11 Comments

C++ program to implement Quick sort Algorithm using class

#include <iostream.h> const int MAX = 10 ; class array { private :   int arr[MAX] ; int count ; public :   array( ) ; void add ( int item ) ; int getcount( ) ; static int split ( int *, int, int ) ; void quiksort ( int lower, int upper ) […]