Saturday, 12 June 2021

A simple C++ Program

Program :

 #include<iostream>

#include<conio.h>

using namespace std;

int main()

{

int i=6;

for(--i;--i;i--)

cout<<i;

getch();

}

Output :




Monday, 25 January 2021

Java Program to implement an interface structure

 Code : 

interface I1

{

  public void comppute1();

}


interface I2 extends I1

{

  public void compute2();

}


Output : 



Java Program to implement the concept of interface

 Code :

interface I1

{

  void compute1();

}

    class B implements I1

    {

      public void compute1()

      {

        System.out.println("Computed Output");

      }

     }

class Main

{

  public static void main()

  {

    B B1 = new B();

    B1.compute1();

  }

}

Output :  

   



Wednesday, 13 January 2021

CPP Program to implement function overloading.

 Code :

#include<iostream>

using namespace std;

int volume(int);

double volume(double,int);

long volume(long,int,int);

int main()

{

cout<< volume(10)<<endl;

cout<< volume(2.5,8)<<endl;

cout<< volume(100,75,15)<<endl;

return 0;

}

int volume(int s)

{

return(s*s*s);

}


double volume(double r,int h)

{

return(3.14519*r*r*h);

}


long volume(long l,int b,int h)

{

return(l*b*h);

}


Output :







Sunday, 10 January 2021

A simple Java program with multiple statements

 Code :


class SquareRoot

{

  public static void main(String args[])

  {

    double x = 5;                 // Declaration and initialization

      double y;                     // Simple declaration

      y = Math.sqrt(x);

      System.out.println("y = " + y);

  }

}


Output : 




A simple Java program to print Hello World

 Code :

class SampleOne

{

  public static void main(String args[])

  {

    System.out.println("Hello World");

  }

}


Output :




Monday, 28 December 2020

Shell program to show palindrome of a number

Code Section :

clear
echo " Enter the number "
read n
number = $n
reverse = 0
while [$n -gt 0]
do
a = 'expr $n%10'
n = 'expr $n/10'
reverse = 'expr $reverse \*10 +$a'
done
echo $reverse
if [$number -eq $reverse]
then
echo "Number is palindrome"
else
echo "Number is not palindrome"
fl