lab programs

No Comments

Java program to Swap the values

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Swap{ public static void main(String args[]){ int num1 = Integer.parseInt(args[0]); int num2 = Integer.parseInt(args[1]); System.out.println("\n***Before Swapping***"); System.out.println("Number 1 : "+num1); System.out.println("Number 2 : "+num2); //Swap logic num1 = num1 + num2; num2 = num1 – num2; num1 = […]

14 Comments

Java program to Display Multiplication Table

1 2 3 4 5 6 7 8 9 10 11 12 class MultiplicationTable{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); System.out.println("*****MULTIPLICATION TABLE*****"); for(int i=1;i<=num;i++){ for(int j=1;j<=num;j++){ System.out.print(" "+i*j+" "); } System.out.print("\n"); } } }

No Comments

Java program to Concatenate natural numbers up to given range

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /* Write a program to Concatenate natural numbers up to given range using for Loop Example: Input – 5 Output – 1 2 3 4 5 */ class Join{ public static void main(String args[]){     int num = […]

1 Comment

Java program to find sum of all integers between 100 & 200 that are divisible by 7

1 2 3 4 5 6 7 8 9 10 11 12 /* Write a program to find sum of all integers greater than 100 and less than 200 that are divisible by 7 */ class SumOfDigit{ public static void main(String args[]){ int result=0; for(int i=100;i<=200;i++){ if(i%7==0) result+=i; } System.out.println("Output of Program is : "+result); […]

78 Comments

Java program to find Fibonacci series of a given number

Java program to find Fibonacci series of a given number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 /*Write a program to find Fibonacci series of a given no. Example : Input – 8 Output – 1 1 2 3 5 8 13 21 […]

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


Electrofriends
Submit Your

Research Papers

Click Here to Submit

Electrofriends
Submit Your

Projects

Click Here to Submit

Free email signup

Get latest projects, articles in your mail box, subscribe to electrifriends

Email:
Recent Questions
    Technical Papers