Showing posts with label addition of two of integer. Show all posts
Showing posts with label addition of two of integer. Show all posts

Saturday, 14 December 2019

Write a java program to swap a two integer without using a Temporary Third variable

Program :
class Swap1
{
    public static void main(String[] args) {
       
        int x = 5 ;
        int y = 7 ;

        x = x +  y ;
        y =  x - y ;
        x = x - y ;

        System.out.println("After Swapping " +x);
        System.out.println("Before Swapping " +y);

    }
}

Output :


Thursday, 12 December 2019

write a java program to find the greatest number among 2 digit.

program :


class Greatest
{
public static void main(String[] args) {
int x = 5 ;
int y = 7 ;

if (x > y ) {

System.out.println(" Greatest Number is " +x);
}

else{

System.out.println("Greatest Number is " +y);
}
}
}

Output :


write a Java program to print Fibonacci Series

Program :


class Fibonacci
{
public static void main(String[] args) {
int fs = 10 , a = 0 ,b =1 , c , i ;
System.out.println("Fibonacci Series");

for (i = 1;i<=fs-2 ;i++ )
                 {
                       c= a+b ;

System.out.println(c);

a= b ;

b = c ;
}

}
}

Output :


Wednesday, 11 December 2019

write a java program to print star design.

program :


class Design
{
public static void main(String args [])
{

System.out.println("* * * * * *");

System.out.println("* * * * * ");

System.out.println("* * * * ");

System.out.println("* * * ");

System.out.println("* * ");

System.out.println("* ");

}
}

Output :


Write a java program to input marks of 5 student if 5 subject out of 100 marks each , output sum and percentage of marks and appropriate division i.e distigusion first class upto fail

Programe : import java.util.*; class Student { public static void main(String args[])     {     Scanner s = ...