Java program to Find Factorial of Given no.

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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); } }

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

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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–; } [...]

Java program to display a greet message according to student marks

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 /* Write a program to display a greet message according to Marks obtained by student. */ class [...]

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

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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)); } } }

Java program to print Small Integer, Largest Integer

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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 [...]

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

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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

Java program to find Maximum of 2 nos

Friday, February 4th, 2011  »  Posted By surajk  »  Total 0 Comment

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); } }

C++ program to implement stack using Linked List

Thursday, February 3rd, 2011  »  Posted By Ranjith  »  Total 1 Comment

#include <iostream.h> template<class T> class Node { friend LinkedStack<T>; private: T data; Node<T> *link; }; template<class T> class LinkedStack { public: LinkedStack() {top = 0;} ~LinkedStack(); int IsEmpty() const {return top == 0;} T Top() const; LinkedStack<T>& Add(const T& x); LinkedStack<T>& Delete(T& x); private: Node<T> *top; }; template<class T> LinkedStack<T>::~LinkedStack() {// Stack destructor.. Node<T> *next; [...]

C++ program to implement Stack using Formula Based Representation

Thursday, February 3rd, 2011  »  Posted By Ranjith  »  Total 1 Comment

#include<iostream.h> #include<constream.h> template<class T> class Stack { public: Stack(int MaxStackSize); ~Stack(){delete[] S;} int IsEmpty()const{return top==-1;} int IsFull()const{return top==MaxTop;} T Peek()const; void Push(T); T Pop(); void Display(); private: int top; //current top of stack int MaxTop; //max val for top T *S; //element array }; template<class T> Stack<T>::Stack(int MaxStackSize) { //stack constructor MaxTop=MaxStackSize-1; S=new T[MaxStackSize]; top=-1; [...]

C++ program to multiply two polynomials maintained as linked lists

Thursday, February 3rd, 2011  »  Posted By Ranjith  »  Total 2 Comments

#include <iostream.h> class poly { private : struct polynode { float coeff ; int exp ; polynode *link ; } *p ; public : poly( ) ; void poly_append ( float c, int e ) ; void display_poly( ) ; void poly_multiply ( poly &p1, poly &p2 ) ; void padd ( float c, int [...]

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup