C program to generate random numbers

This c program generates pseudo random numbers using rand and random function(Turbo C compiler only). As the random numbers are generated by an algorithm used in a function they are pseudo random, this is the reason why pseudo word is used. Function rand() returns a pseudo random number between 0 and RAND_MAX. RAND_MAX is a constant which is platform dependent and equals the maximum value returned by rand function.

We use modulus operator in our program. If you evaluate a % b where a and b are integers then result will always be less than b for any set of values of a and b. For example
For a = 1243 and b = 100
a % b = 1243 % 100 = 43
For a = 99 and b = 100
a % b = 99 % 100 = 99
For a = 1000 and b = 100
a % b = 1000 % 100 = 0

In our program we print pseudo random numbers in range [0, 100]. So we calculate rand() % 100 which will return a number in [0, 99] so we add 1 to get the desired range.

#include <stdio.h>
#include <stdlib.h>

int main() {
  int c, n;

  printf("Ten random numbers in [1,100]\n");

  for (c = 1; c <= 10; c++) {
    n = rand() % 100 + 1;
    printf("%d\n", n);
  }

  return 0;
}

If you rerun this program you will get same set of numbers. To get different numbers every time you can use: srand(unisgned int seed) function, here seed is an unsigned integer. So you will need a different value of seed every time you run the program for that you can use current time which will always be different so you will get a different set of numbers. By default seed = 1 if you do not use srand function.

C programming code using random function(Turbo C compiler only)

randomize function is used to initialize random number generator. If you don't use it then you will get same random numbers each time you run the program.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

int main()
{
   int n, max, num, c;

   printf("Enter the number of random numbers you want\n");
   scanf("%d", &n);

   printf("Enter the maximum value of random number\n");
   scanf("%d", &max);

   printf("%d random numbers from 0 to %d are :-\n", n, max);

   randomize();

   for (c = 1; c <= n; c++)
   {
      num = random(max);
      printf("%d\n",num);      
   }

   getch();
   return 0;
}

Add two Complex number

C program to add two complex numbers: this program calculate the sum of two complex numbers which will be entered by the user and then prints it. User will have to enter the real and imaginary parts of two complex numbers. In our program we will add real parts and imaginary parts of complex numbers and prints the complex number, i is the symbol used for iota. For example if user entered two complex numbers as (1 + 2i) and (4 + 6 i) then output of program will be (5+8i). A structure is used to store complex number.

C programming code


#include <stdio.h>

struct complex
{
   int real, img;
};

int main()
{
   struct complex a, b, c;

   printf("Enter a and b where a + ib is the first complex number.\n");
   printf("a = ");
   scanf("%d", &a.real);
   printf("b = ");
   scanf("%d", &a.img);
   printf("Enter c and d where c + id is the second complex number.\n");
   printf("c = ");
   scanf("%d", &b.real);
   printf("d = ");
   scanf("%d", &b.img);

   c.real = a.real + b.real;
   c.img = a.img + b.img;

   if ( c.img >= 0 )
      printf("Sum of two complex numbers = %d + %di\n", c.real, c.img);
   else
      printf("Sum of two complex numbers = %d %di\n", c.real, c.img);

   return 0;
}

Palindrome Number

Palindrome number in c: A palindrome number is a number such that if we reverse it, it will not change. For example some palindrome numbers examples are 121, 212, 12321, -454. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not. C program for palindrome number is given below.

Palindrome number algorithm

1. Get the number from user.
2. Reverse it.
3. Compare it with the number entered by the user.
4. If both are same then print palindrome number
5. Else print not a palindrome number.

Palindrome number program c

#include <stdio.h>

int main()
{
   int n, reverse = 0, temp;

   printf("Enter a number to check if it is a palindrome or not\n");
   scanf("%d",&n);

   temp = n;

   while( temp != 0 )
   {
      reverse = reverse * 10;
      reverse = reverse + temp%10;
      temp = temp/10;
   }

   if ( n == reverse )
      printf("%d is a palindrome number.\n", n);
   else
      printf("%d is not a palindrome number.\n", n);

   return 0;

}

Predict the output (or) error(s) for the following 6-10

6.     main()
            {
            extern int i;
            i=20;
            printf("%d",i);
            }
Answer:
            Linker Error : Undefined symbol ' I '
Explanation:
            extern storage class in the following declaration, extern int i; specifies to the compiler that the memory for i is  allocated in some other program and that address will be given to the current Program at the time of linking. But linker finds that no other variable of name i is available in any output.

7.     main()
            {
            int i=-1,j=-1,k=0,l=2,m;
            m=i++&&j++&&k++||l++;
            printf("%d %d %d %d %d",i,j,k,l,m);
            }
Answer:
            0 0 1 3 1
Explanation :
            Logical operations always give a result of 1 or 0 . And also the logical AND (&&) operator has higher priority over the logical OR (||) operator. So the expression ‘i++ && j++ && k++’ is executed first. The result of this expression is 0 (-1 && -1 && 0 = 0). Now the expression is 0 || 2 which evaluates to 1 (because OR operator always gives 1 except for ‘0 || 0’ combination for
which it gives 0). So the value of m is 1. The values of other variables are also incremented by 1.

8.    main()
            {
            char *p;
            printf("%d %d ",sizeof(*p),sizeof(p));
            }
Answer:
            1 2
Explanation:
            The sizeof() operator gives the number of bytes taken by its operand. P is a character pointer, which needs one byte for storing its value (a character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store the address of the character pointer sizeof(p) gives 2.her program with memory space allocated for it. Hence a linker error has occurred

9.     main()
            {
            int i=3;
            switch(i)
            {
            default:printf("zero");
            case 1: printf("one");
            break;
            case 2:printf("two");
            break;
            case 3: printf("three");
            break;
            }
            }

Answer :
            Three
Explanation :
            The default case can be placed anywhere inside the loop. It is executed only when all other cases doesn't match.

10.    main()
            {
            printf("%x",-1<<4);
            }
Answer:
            fff0
Explanation :
            -1 is internally represented as all 1's. When left shifted four times the least significant 4 bits are filled with 0's.The %x format specifier specifies that the integer value be printed as a hexadecimal value.

Predict the output (or) error(s) for the following 1 - 5


1.      void main()
            {
            int const * p=5;
            printf("%d",++(*p));
            }
Answer:
            Compiler error: Cannot modify a constant value.
Explanation:
            p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".

2.    main()
            {
            char s[ ]="man";
            int i;
            for(i=0;s[ i ];i++)
            printf("\n%c%c%c%c",
            s[ i ],*(s+i),*(i+s),i[s]);
            }

Answer:
mmmm
aaaa
nnnn
Explanation:
            s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address.    I is the index number/displacement from the  as address. So, in directing it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

3.     main()
            {
            float me = 1.1;
            double you = 1.1;
            if(me==you)
            printf("I love U");
            else
            printf("I hate U");
            }

Answer:
            I hate U
Explanation:
            For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
            Never compare or at-least be cautious when using floating point numbers with relational operators.                           (== , >, <, <=, >=,!= ) .

4.     main()
            {
            static int var = 5;
            printf("%d ",var--);
            if(var)
            main();
            }
Answer:
            5 4 3 2 1
Explanation:
            When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like
any other ordinary function, which can be called recursively.

5.     main()
            {
            int c[ ]={2.8,3.4,4,6.7,5};
            int j,*p=c,*q=c;
            for(j=0;j<5;j++)
             {
            printf(" %d ",*c);
            ++q;
             }
            for(j=0;j<5;j++)
            {
            printf(" %d ",*p);
            ++p;
            }
            }
Answer:
            2 2 2 2 2 2 3 4 6 5
Explanation:

            Initially pointer c is assigned to both p and q. In the first loop, since only q is incremented and not c , the value 2 will be printed 5 times. In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed.

C program to find E-series.


#include<stdio.h>
#include<conio.h>
void main()
{
float y,sum;
int a,n,i;
clrscr();
printf("Enter the y value");
scanf("%f",&y);
printf("\n Number of terms");
scanf("%d",&n);
  if(n==1)
  {
  sum=1;
  }
    else if(n==2)
   {
    sum=y+1;
   }
      else
      {
        a=1;
for(i=2;i<n;i++)
{
a=a*i;
sum=sum+pow(y,i)/a;
}
     }
printf("\n y value=%f",y);
printf("\n No of terms=%d",n);
printf("\n Eseries=%f",sum);
getch();
}

Calculate GCD Value


#include<stdio.h>
#include<conio.h>
int gcd(int a,int b)
{
if(a<0)
 a=-a;
if(b<0)
 b=-b;
if(a==0||b==1||a==b)
return b;
if(a==1||b==0)
return a;
if(a>b)
return gcd(b,a%b);
else
return gcd(a,b%a);
}
void main()
{
int x,y;
clrscr();
printf("\nEnter the 1st Number:");
scanf("%d",&x);
printf("\nEnter the 2nd Number:");
scanf("%d",&y);
printf("\n GCD value is %d",gcd(x,y));
getch();
}                                                     

Transpose Matrix


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,m,row,col,a[10][10];
clrscr();
printf("Enter the Rows&col:\n");
scanf("%d %d",&row,&col);
printf("\nEnter the values of matrix:\n");
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nGiven Matrix:\n");
for(i=0;i<col;i++)
{
for(j=0;j<row;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n\n");
}

printf("\nTranspose Matrix:\n");
for(i=0;i<col;i++)
{
for(j=0;j<row;j++)
{
printf("%d\t",a[j][i]);
}
printf("\n\n");
}
getch();
}

OUTPUT:


Enter the Rows&col:

2       2

Enter the values of matrix:

2

4

6

8

Given matrix

2        4

6       8



Transpose Matrix:

2       6
                                                                           
4       8     

Bouncing Ball

#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\turboc++\disk\\turboc3\\bgi");
setbkcolor(11);
setcolor(WHITE);
int x=145,y=300,xd=1,yd=1;
while(!kbhit())
{
cleardevice();
outtextxy(50,50,"Bouncing Ball");
if(x<50 || x>570)
xd=-xd;
if(y<50 || y>455)
yd=-yd;
x=x+xd;
y=y+yd;
circle(x,y,20);
setfillstyle(1,5);
floodfill(x,y,15);
delay(10);
}

getch();
}

Ball in Random Location

#include<graphics.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
void main()
{
clrscr();
int gd=DETECT,gm,x,y;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(11);
cout<<"\n\t\tBalls in Random Location";
cout<<"\n\t\t************************";
while(!kbhit())
{
setcolor(RED);
rectangle(40,90,560,400);
x=random(590);
y=random(390);
if(x>75&&y>100&&x<500&&y<400)
{
setcolor(random(5));
circle(x,y,10);
delay(100);
}
}
}

News headline (Letter by letter)




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

void main()
{
int gd=DETECT,gm;
clrscr();
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(BLUE);
setcolor(WHITE);

int i,n;
int x=10;
char a[20][20];

cout<<"\n\t\t Letter by Letter(News headlines)";
cout<<"\n\t\t ********************************";
cout<<"\n\t Enter the number of letters\n";
cin>>n;


cout<<"\n\tEnter the news\n";
for(i=0;i<n;i++)
cin>>a[i];

while(!kbhit())
{
 cleardevice();
settextstyle(3,0,4);
 for(i=0;i<n;i++)
 {
 outtextxy((x+i)*20,200,a[i]);
delay(250);
 }
}
getch();

}

Dropping word by word

#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
void main()
{
char a[20],b[20],c[20];
clrscr();
int gd=DETECT,gm,i,j,k;
initgraph(&gd,&gm,"c:\\turboc++\\disk\\turboc3\\bgi");
setbkcolor(11);
cout<<"\n\t\tDropping Word by word";
cout<<"\n\t\t*********************\n";
cout<<"\n\tEnter the any three words \n";
cout<<"\tWord 1=";
cin>>a;
cout<<"\tWord 2=";
cin>>b;
cout<<"\tWord 3=";
cin>>c;
for(i=0;i<400;i++)
{
cleardevice();
outtextxy(50,i,a);
outtextxy(200,10,b);
outtextxy(400,10,c);
delay(10);
}
for(j=0;j<400;j++)
{
cleardevice();
outtextxy(50,i,a);
outtextxy(200,j,b);
outtextxy(400,10,c);
delay(10);
}
for(k=0;k<400;k++)
{
cleardevice();
outtextxy(50,i,a);
outtextxy(200,j,b);
outtextxy(400,k,c);
delay(10);
}
getch();

}

Tile and Cascade Image

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,n=0;
initgraph(&gd,&gm,"C:\\tc\\bgi");
setbkcolor(11);
  do
  {
  cout<<"\n\t\t Tile and Cascade Image";
  cout<<"\n\t\t***********************\n";
  cout<<"\t\t1.Tile\n\t\t2.Cascade\n\t\t3.Exit";
  cout<<"\n\t Enter your choice\n\n";
  cin>>n;
  clrscr();
  cleardevice();
     switch(n)
    {
      case 1:
      outtextxy(170,130,"Tile Image");
      rectangle(200,200,150,150);
      rectangle(280,200,230,150);
      rectangle(200,280,150,230);
      rectangle(280,280,230,230);
      break;
      case 2:
      outtextxy(170,130,"Cascade image");
      rectangle(200,200,150,150);
      rectangle(220,220,170,170);
      rectangle(240,240,190,190);
      rectangle(260,260,210,210);
      break;
    }
  }while(n<3);

}

Bresenham's Circle drawing Algorithem

#include <iostream.h>
#include<conio.h>
#include <dos.h>
#include <graphics.h>
void drawCircle(int xc, int yc, int x, int y)
{
putpixel(xc+x, yc+y, WHITE);
putpixel(xc-x, yc+y, WHITE);
putpixel(xc+x, yc-y, WHITE);
putpixel(xc-x, yc-y, WHITE);
putpixel(xc+y, yc+x, WHITE);
putpixel(xc-y, yc+x, WHITE);
putpixel(xc+y, yc-x, WHITE);
putpixel(xc-y, yc-x, WHITE);
}
void circleBres(int xc, int yc, int r)
{
int x = 0, y = r;
int d = 3 - 2 * r;
while (x < y)
{
drawCircle(xc, yc, x, y);
x++;

if (d < 0)
d = d + 4 * x + 6;
else
{
y--;
d = d + 4 * (x - y) + 10;
}
delay(100);
}
}
void main()
{
int xc, yc, r;
int gd = DETECT, gm;
initgraph(&gd, &gm, "c:\\tc\\bgi");
setbkcolor(11);
cout<<"\n\t\tBresenham's Circle drawing Algoritham";
cout<<"\n\t\t*************************************\n";
cout<<"\n\tEnter coordinates of circle:\n";
cout<<"\tXc=";
cin>>xc;
cout<<"\tYc=";
cin>>yc;
cout<<"\n\tRadius of circle=";
cin>>r;
circleBres(xc, yc, r);
getch();
}

Bresenham line Drawing Algorithm

#include<iostream.h>
#include <dos.h>
#include<conio.h>
#include <graphics.h>
#include<stdlib.h>
void lineBres(int xa, int ya, int xb, int yb)
{
int dx = abs(xb - xa), dy =abs(yb - ya);
int twodx = 2 * dy - dx;
int twody = 2 * dy;
int p = 2 * (dy - dx);
putpixel(xa, ya, RED);
while (xa < xb)
{
xa++;
if (twodx < 0)
twodx +=twody;
else
{
ya++;
twodx +=p;
}
putpixel(xa, ya, RED);
delay(20);
}
}


void main()
{
int a,b,c,d;
int gd = DETECT, gm;
initgraph(&gd, &gm, "c:\\tc\\bgi");
cout<<"\n\t\tBresenham's Line Drawing Algorithm";
cout<<"\n\t\t**********************************";
cout<<"\n\tEnter following coordinates for a line";
cout<<"\n\txa=";
cin>>a;
cout<<"\tya=";
cin>>b;
cout<<"\txb=";
cin>>c;
cout<<"\tyb=";
cin>>d;
lineBres(a,b,c,d);
getch();

}

DDA line Drawing Algorithm

#include<iostream.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
void lineDDA(int xa,int ya,int xb,int yb)
{
int dx=xb-xa,dy=yb-ya,steps,k;
float xi,yi,x=xa,y=ya;
if(abs(dx)>abs(dy))
steps=abs(dx);
else
steps=abs(dy);
xi=dx/(float)steps;
yi=dy/(float)steps;
putpixel(x,y,WHITE);
for(k=0;k<steps;k++)
{
x+=xi;
y+=yi;
putpixel(x,y,WHITE);
}
}
void main()
{
int gd=DETECT,gm,a,b,c,d;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(11);
//setcolor(WHITE);
cout<<"\n\t\tDDA algorithm for line";
cout<<"\n\t\t**********************";
cout<<"\n\tEnter the coordinates\n";
cout<<"\txa=";
cin>>a;
cout<<"\tYa=";
cin>>b;
cout<<"\tXb=";
cin>>c;
cout<<"\tYb=";
cin>>d;
lineDDA(a,b,c,d);
getch();
}

Scale an image

#include<graphics.h>
#include<stdlib.h>
#include<iostream.h>
#include<conio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,n,i,t;
int array1[20],array2[20];
int array[]={340,70,390,120,370,170,290,120,340,70};
initgraph(&gd,&gm,"c:\\tc\\bgi");
//setcolor(BLACK);
setbkcolor(11);
do
{
drawpoly(6,array);
for(i=0;i<12;i++)
array1[i]=array[i]*.75;
for(i=0;i<12;i++)
array2[i]=array[i]*1.5;
cout<<"\n\n\t\t\t Scale an Image";
cout<<"\n\t\t\t*****************";
cout<<"\n\t\t1.Shrink";
cout<<"\n\t\t2.grow";
cout<<"\n\t\t3.Exit";
cout<<"\n\tEnter your choice\n";
cin>>n;
switch(n)
{
case 1:
cleardevice();
drawpoly(6,array1);
delay(10);
break;
case 2:
cleardevice();
drawpoly(6,array2);
delay(10);
break;
case 3:
goto s;
}
}while(n<=2);
s:
exit(0);
getch();

}

Rotation of an Image

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(11);
setcolor(BLACK);
float a,b;
int x1,x2,x3,y1,y2,y3;
outtextxy(250,100,"Original Image");
line(210,180,370,180);
line(210,180,280,120);
line(370,180,280,120);
cout<<"\n\n\t\tRotation of an Image";
cout<<"\n\t\t********************\n";
cout<<"\n\tEnter the angle =";
cin>>a;
x1=60*cos((a-45)*(3.14/180))+300;
y1=60*sin((a-45)*(3.14/180))+300;
x2=60*cos((a+45)*(3.14/180))+300;
y2=60*sin((a+45)*(3.14/180))+300;
x3=60*cos((b-45)*(3.14/180))+300;
y3=60*sin((b-45)*(3.14/180))+300;
outtextxy(270,380,"After Roation");
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
getch();
}

Translation of an image

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(11);
//setcolor(BLACK);
int xa=150,ya=250,xb=250,yb=150,ch;
do
{
clrscr();
cleardevice();
rectangle(xa,ya,xb,yb);
cout<<"\n\t1.Left\n\t2.Right\n\t3.Up\n\t4.Down\n\t5.Exit";
cout<<"\n Enter your choice\n";
cin>>ch;
   switch(ch)
   {
   case 1:
     xa-=10;
     xb-=10;
     break;
   case 2:
     xa+=10;
     xb+=10;
     break;
   case 3:
     ya-=10;
     yb-=10;
     break;
   case 4:
     ya+=10;
     yb+=10;
     break;
    }
}while(ch<5);
}

Decimal To Binary

package sample.Java;

import java.util.Scanner;

/**
 *
 * @author Brilliant student
 */
public class NTB {
    public static void main(String abc[])
{
    int j=0,n,i=0;
    int a[]=new int[30];
    int b[]=new int[30];
    Scanner s=new Scanner(System.in);
    System.out.println("Enter any number");
    n=s.nextInt();
    while(n!=0)
    {
        a[i]=n%2;
        n=n/2;
        i++;
    }
    n=i;
    for(i=n;i>0;i--)    
    {
        b[j]=a[i];
        j++;
    }
    System.out.print("Binary number is=");
    for(i=0;i<j;i++)
        System.out.print(""+b[i]);
  }
}

Identify Number System



import java.util.Scanner;
class INS
{
    int i=0,j=0,temp=0,sum=0,digit=0;
    void strong(int n)
    {
        j=n;
        while(j>0)           
        {
            temp=j%10;
            j=j/10;
            sum+=fact(temp);
        }
        if(n==sum)
            System.out.println("1. Given Number is Strong Number");
        else
            System.out.println("1. Given Number is Not Strong number");
    }

    void vampire(int n)
    {
        sum=0;
        int vam,rev;
        rev=n/100;
        temp=reverse(rev);
        vam=n%100;
        sum=vam*temp;      
        if(n==sum)
            System.out.println("2. Given Number is Vampire Number");
        else
            System.out.println("2. Given Number is Not vampire number");
    }

    void perfect(int n)
    {
        sum=0;
        for(i=1;i<n;i++)
          {
            j=n%i;
            if(j==0)
                sum=sum+i;
          }
        if(n==sum)
            System.out.println("3. Given Number is Perefect Number");
        else
            System.out.println("3. Given Number is Not perfect number");
    }

    void palindrome(int n)
    {
        int rev= reverse(n);
        if(n==rev)
            System.out.println("4. Given Number is Palindrome");
        else
            System.out.println("4. Given Number is Not palindrome");
    }

    void amstrong(int n)
    {
        sum=0;   temp=n;
        while(n>0)
        {
            digit=n%10;
            n=n/10;
            sum=sum+digit*digit*digit;
     }
        if(temp==sum)
            System.out.println("5. Given Number is Amstrong");
        else
            System.out.println("5. Given Number is Not Amstrong");
    }

    void odd(int n)
    {
        if((n&1)==0)
        System.out.println("6. Given Number is Even");
        else
        System.out.println("6. Given Number is ODD");
    }

    int reverse(int r)
    {
        sum=0;
        while(r>0)
        {
            digit=r%10;
            r=r/10;
            sum=sum*10+digit;
        }
        return(sum);
    }

    int fact(int f)
    {
        int fac=1;
        for(i=1;i<=f;i++)       
            fac=fac*i;
        return(fac);
    }

    }






public class SDL_INS_2015
{
    public static void main(String[] SoftwareDevelopmentLab2015)
    {
        int num;
        Scanner s=new Scanner(System.in);
        System.out.println("Identify Number System");
        System.out.println("**********************");
        System.out.println();
        System.out.print("Enter any number");
        num=s.nextInt();
        System.out.println();
        System.out.println("Result:");
        System.out.println("*******");
        System.out.println();
        INS i=new INS();
        i.strong(num);
        i.vampire(num);
        i.perfect(num);
        i.palindrome(num); 
        i.amstrong(num);
        i.odd(num);
     }
}



OUTPUT:-
A .      
             Identify Number System
********************
Enter any number 145
Result:
*******
1. Given Number is Strong Number
2. Given Number is Not vampire number
3. Given Number is Not perfect number
4. Given Number is Not palindrome
5. Given Number is Not Amstrong
6. Given Number is ODD

B .   
             Identify Number System
********************
Enter any number 1260
Result:
*****
1. Given Number is Not Strong number
2. Given Number is Vampire Number
3. Given Number is Not perfect number
4. Given Number is Not palindrome
5. Given Number is Not Amstrong
6. Given Number is Even
C .      
             Identify Number System
********************
Enter any number28
Result:
*****
1. Given Number is Not Strong number
2. Given Number is Not vampire number
3. Given Number is Perefect Number
4. Given Number is Not palindrome
5. Given Number is Not Amstrong
6. Given Number is Even
D.
Identify Number System
********************
Enter any number153
Result:
*******
1. Given Number is Not Strong number
2. Given Number is Not vampire number
3. Given Number is Not perfect number
4. Given Number is Not palindrome
5. Given Number is Amstrong
6. Given Number is ODD



E.        
             Identify Number System
          ********************
Enter any number121
Result:
*******
1. Given Number is Not Strong number
2. Given Number is Not vampire number
3. Given Number is Not perfect number
4. Given Number is Palindrome
5. Given Number is Not Amstrong

6. Given Number is ODD