programme for armstrong number for 3 digit in java

armstrong number


import java.util.Scanner;
class Mittu
{
    public static void main(String []args)
    {
        Scanner s=new Scanner(System.in);
        int n,x,y,z,t;
        System.out.println("enter any three digit number");
        n=s.nextInt();
        t=n;
        x=n/100;
        n=n%100;
        y=n/10;
        n=n%10;
        z=n/1;
        n=n%1;
        z=x*x*x+y*y*y+z*z*z;
                System.out.println(z);    

        if(t==z)
        System.out.println("it is armstrong number");    
        else
        System.out.println("it is not armstrong number");        
    }
}

output

enter any three digit number
407
407
it is armstrong number

rogramme for take three digit number and print it in revere order in java

rogramme for take three digit number and print it in revere order


import java.util.Scanner;
class Mittu
{
    public static void main(String []args)
    {
        Scanner s=new Scanner(System.in);
        int n,x,y,z;
        System.out.println("enter any three digit number");
        n=s.nextInt();
        x=n/100;
        n=n%100;
        y=n/10;
        n=n%10;
        z=n/1;
        n=n%1;
                System.out.println("number in reverse order");
                System.out.print(z);
                System.out.print(y);
                System.out.print(x);    
    }
}

out put

enter any three digit number
153
number in reverse order
351

how to print star tringle in java

(4)programme for star tringle

import java.util.Scanner;
class Mittu
{
    public static void main(String []args)
    {
        int i,j,k;
        for(i=1;i<=5;i++)
        {
        for(j=5;j>=i;j--)
          System.out.print(" ");
        for(k=1;k<=i;k++)
            System.out.print("* ");
        System.out.println();
        }
    }
}

output

          * 
        * * 
      * * * 
    * * * * 
   * * * * * 

how to make programme for shorting in java programme

(3)programme for shorting

import java.util.Scanner;
class Mittu
{
    public static void main(String []args)
    {
        Scanner s=new Scanner(System.in);
        int i,t,j,n;
        System.out.println("enter size of array");  
        n=s.nextInt();
        int x[]=new int[n];
              System.out.println("enter "+n+" 5elements");
        for(i=0;i<n;i++)
             for(i=0;i<n;i++)
        x[i]=s.nextInt();      
        for(j=0;j<n-1;j++)
        for(i=j+1;i<n;i++)
            if(x[j]>x[i])
            {
                t=x[i];
                x[i]=x[j];
                x[j]=t;
            }
                      System.out.println("after shorting");
        for(i=0;i<n;i++)
            System.out.println(x[i]);
    }
}

output

enter size of array
10
enter 10 5elements
8
6
4
2
9
7
5
3
1
10
after shorting
1
2
3
4
5
6
7
8
9
10

how to print febonocci serise in java programme

(1)febonocci serise


class Mittu
{
    public static void main(String []args)
     {
        int i,x=0,y=1,z,n=10;
        System.out.println("febonocci serise is");
        System.out.println(x);
        System.out.println(y);
        
        for(i=2;i<n;i++)
        {
            z=x+y;
            System.out.println(z);
            y=x;
            x=z;
        }
     }
}

output

febonocci serise is
0
1
1
1
2
3
5
8
13
21

Program of Fibonacci Series in C++

#include<iostream>
using namespace std;
int main()
{
int x=0,y=1,z,i,t;
cout<<"enter any number\n";
cin>>z;
cout<<x<<endl;
for(i=2;i<z;i++)
{
t=x+y;
cout<<t<<endl;
y=x;
x=t;
}
getch();
}

Programming in C++ Printing your name or string without semicolon

#include<iostream>
#include<conio.h>

using namespace std;
int main()
{
if(cout<<"mittu parmar"&&getch())
{
}
}

Programming in C++ Swapping two number without third variable

#include<iostream>
using namespace std;
int main()
{
int a,b;
cout<<"enter two numbers\n";
cin>>a;
b=a;
cin>>a;
cout<<"swap of two no. is\n"<<a<<b;
}

Programming in C++ Swapping of two Integers

#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"enter two numbers\n";
cin>>a>>b;
c=a;
a=b;
b=c;
cout<<"swap of two no. is\n"<<a<<b;
}

how to find smallest number in array in c++

how to find smallest number in array in c++

#include<iostream>
using namespace std;
main()
{
cout<<"enter 10 numbers for find smallest number from 10 numbers\n";
int a[10],i;
for(i=0;i<10;i++)
cin>>a[i];
int small=a[0];
for(i=0;i<10;i++)
if(a[i]>a[i+1])
small=a[i+1];
cout<<"smallest number is\n";
cout<<small;
}

programme for armstrong number for 3 digit in java

armstrong number import java.util.Scanner; class Mittu {     public static void main(String []args)     {         Scanner s=new Sca...