Wednesday, 27 March 2013

Find the binary value of given decimal value

#include<stdio.h>
#include<conio.h>
void main()
{
    int n,rem=0,j,i=0,dec[20],temp;
    clrscr();
    printf("\n\t\tThe Software creadet by Dixit Panchal\n");
    printf("\t\tEnter Your decimal Value \n\n");
    scanf("%d",&n);
    temp=n;
    while(n>0)
    {
     rem=n%2;
     n/=2;
     dec[i]=rem;
     i++;


    }
    printf("\nYour Decimal number is %d",temp);
    printf("\nAnd binary is ");
    for(j=i-1 ;j>=0;j--)
    {
       printf("%d",dec[j]);
    }

    getch();


}

Find the Hexa decimal value of Decimal value using C programm

#include<stdio.h>
#include<conio.h>
void main()
{
   int  a,no,i=0,*p;
   clrscr();
   printf("\tEnter your value which you want get Hexadecimal value.\n");
   printf("\n\n\tPlease enter your value here.\n");
   scanf("%d",&no);
while(no>i)
   {
    a=no%16;
    if(a<=9)
    printf(" %d",a);
    else
    break;
    no=no/16;
    }
switch(no)
      {
      case 10:
      no='A';
      printf("%c",no);
      break;
      case 11:
      no='B';
      printf("%c",no);
      break;
      case 12:
      no='C';
      printf("%c",no);
      break;
      case 13:
      no='D';
      printf("%c",no);
      break;
      case 14:
      no='E';
      printf("%c",no);
      break;
      case 15:
      no='F';
      printf("%c",no);
      break;
      default:
      printf("%d",no);
      break;
      }
getch();
}


Sunday, 24 March 2013

A Java Program which show the use of Methods Overloading. //DemoStrate Method OverLoading....


class OverLoadDemo
{
void test()
{
System.out.println("No Parameters");
}
//OverLoad Test for One Integer Parameters.....
void test(int a)
{
System.out.println("a:"+a);
}
//Overload test for two Integer Parameters.....
void test(int a,int b)
{
System.out.println(" a :" +a+ " b :"+b);
}
//OverLoad test for a Double Parameters.....
double test(double a)
{
System.out.println("Double a:"+a);
return a*a;
}
}
class OverLoad
{
public static void main(String args[])
{
OverLoadDemo ob=new OverLoadDemo();
double result;
//Call all Versions of test()......
ob.test();
ob.test(10);

ob.test(10,20);
result=ob.test(123.2);
System.out.println("Result of ob.test(123.2): "+result);
}
}

A Java Program which show the Application of Constructors.


class Box
{
double width;
double height;
double depth;
//This is the Constructor for Box....
Box(double w,double h,double d)
{
width=w;
height=h;
depth=d;
}
//Compute and Reture Volume....
double volume()
{
return width*height*depth;
}
}
class BoxDemo
{
public static void main(String args[])
{
//Declare,Alocate and initialize Box Object
Box myBox1=new Box(10,20,15);
Box myBox2=new Box(3,6,9);
double vol;
//Get volume of First Box....
vol=myBox1.volume();
System.out.println("Box1 Volume is:-> "+vol);
//Get Volume of Second Box....
vol=myBox2.volume();
System.out.println("Box2 Volume is:-> "+vol);
}
}

A Java Program which will read a String and Rewrite it in the Alphabetical Order.


e.g. The word “STRING” should be written a “GNIRST”.
import java.io.*;
import java.util.*;
class Alphabatic
{
String alphaOrder(String str)
{
char[] charArray=str.toCharArray();
Arrays.sort(charArray);
String aString=new String(charArray);
return aString;
}
public static void main(String[] args)throws IOException
{
System.out.println("Enter the String->");
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
String inputString=br.readLine();
Alphabatic obj=new Alphabatic();
String alphaString=obj.alphaOrder(inputString);
System.out.println("String in the Alphabetic Order :" +alphaString);
}
}

A Java Program to Sort the Elements of an Array in Ascending Order.


import java.io.*;
class array
{
public static void main(String args[])throws IOException
{
System.out.println("Enter the Length of Array:->");
DataInputStream br=new DataInputStream(System.in);
String s=br.readLine();
int n=Integer.parseInt(s);
int arr[]=new int[n];
int i=0,j,temp=0;
for(i=0;i<n;i++)
{
System.out.println("Enter the value of ["+i+"]: ->");
arr[i]=Integer.parseInt(br.readLine());
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(i=0;i<n;i++)
{
System.out.println("The Value of array["+i+"] is:->"+arr[i]);
}
}
}

A Java Program that will accept Command line Arguments and Display the same.


import java.io.*;
class pr5
{
public static void main(String args[]) throws IOException
{
DataInputStream br=new DataInputStream(System.in);
System.out.println("Enter your String :->");
String str=br.readLine();
System.out.println("Your string is :->"+str);
}
}

A Java Program for Display 25 Prime Numbers.

class prime
{
public static void main(String args[])
{
int i,j,a=0,m=1;
for(i=1;i<=250;i++)
{ a=0;
for(j=2;j<=i-1;j++)
{
if(i%j==0)
{
a=1;
}
}
if(a!=1 && m<=25)
{
System.out.println(+i);
m=m+1;
}
}
}
}

A Java Program for Find the Factorial of given number Using Command line Arguments.


import java.io.*;
class pr2
{
public static void main(String args[])throws IOException
{
DataInputStream br=new DataInputStream(System.in);
System.out.println("Enter the Number:->");
int No=Integer.parseInt(br.readLine());
int fact=1,i=1;
for(i=1;i<=No;i++)
{
fact=fact*i;
}
System.out.println("The Factorial of ["+No+"] is :=>"+fact);
}
}

Saturday, 23 March 2013

Circuler Linked List in C++

/*
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    ::::  THIS PROGRAMM INDICATES THE CONCEPT OF CIRCULER      ::::
    ::::                LINKED LIST                            ::::
    ::::  CREATED BY : DX PANCHAL(M.C.A.)  DATED:08/03/2013     ::::
    ::::  PROGRAMMING LANGUAGE : c++                           ::::
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

*/
#include<iostream.h>
#include<conio.h>
#include<malloc.h>
#include<dos.h>
#include<process.h>
struct list
{
  int info;
  struct list *next;

};

typedef struct list *newnode;
newnode first,newn,temp,save,avail,head,pred;
void main()
{
 int ch,i,choice;
 textcolor(WHITE);
 clrscr();
 first=NULL;
 avail=(newnode)malloc(sizeof(struct list));
 avail->next=NULL;
 cout<<"\n\t\tENTER VALUES YOU WANT TO CREATE NODE\n";
 cin>>ch;
 temp=avail;
 for(i=1;i<ch;i++)
 {
  temp->next=(newnode)malloc(sizeof(struct list));
  temp=temp->next;
  temp->next=NULL;

 }
 cout<<"\n\t\tYOU HAVE "<<ch<<"  NODE SUCCESSFULLY CREATED....!!!";
 getch();

 do
 {

  clrscr();
  cout<<"\n\t\t ";
  cout<<"\n\t\t| CIRCLUER LINKED LIST MENU      |";
  cout<<"\n\t\t|________________________________|\n";
  cout<<"\n\t\t                                  ";
  cout<<"\n\t\t[1] FOR INSERT NODE               ";
  //cout<<"\n\t\t[3] FOR INSERT NODE AS ORDER      ";
 // cout<<"\n\t\t[4] FOR DELETE NODE AT FIRST      ";
  //cout<<"\n\t\t[5] FOR DELETE NODE AT LAST       ";
  cout<<"\n\t\t[2] FOR DELETE NODE       ";
  cout<<"\n\t\t[3] FOR DISPLAY NODE LIST         ";

  cout<<"\n\t\t[0] FOR EXIT                      ";
  cout<<"\n\t\t ";
  cin>>choice;
  switch(choice)
  {


     case 1:
      if(avail==NULL)
       {
         cout<<"\n\t\t";
         textcolor(RED+BLINK);
         cprintf("NO NODE AVAILABLE FOR INSERT OPERATION..!!!");
         textcolor(WHITE);

       }
       else
       {
         newn=avail;
         avail=avail->next;
         cout<<"\n\t\tENTER VALUE FOR NODE ";
         cin>>newn->info;
         if(first==NULL)
         {
          head->info=NULL;

          newn->next=NULL;
          first=newn;
          head->next=first;
         }
         else
         {
         save=first;
         while(save->next!=head)
         {
          save=save->next;
         }
         save->next=newn;
         newn->next=head;


         }
          cout<<"\n\t\tOPERATION SUCCESSFULL..!!!";

       }
       getch();
       break;
    case 2:

       if(first==NULL)
       {
         cout<<"\n\t\t";
         textcolor(RED+BLINK);
         cprintf("NO NODE AVAILABLE FOR DELETE OPERATION..!!!");
         textcolor(WHITE);
       }
       else
       {
        temp=first;
        int selected;
        cout<<"\n\t\tENTER NODE DATA WHICH YOU WANT TO DELETE..!!!";
        cin>>selected;
        while(temp->info!=selected&&temp!=NULL)
        {
         pred=temp;
         temp=temp->next;
        }
        pred->next=temp->next;
        if(temp->info!=selected)
        {
          cout<<"\n\t\t";
         textcolor(RED+BLINK);
         cprintf("OH,SORRY SELECTED NODE NOT FOUND..!!!");
         textcolor(WHITE);


        }
        else
        {
        cout<<"\n\t\tSELECTED NODE  |"<<temp->info<<"| IS DELETED SUCCESSFULLY...!!!";

        avail=temp->next;
        avail=temp;

          }
       }
       getch();
       break;
    case 3:
       cout<<"\n\t\t ";
       cout<<"\n\t\t TOTAL NODE IN  LIST";
       if(first==NULL)
       {
         cout<<"\n\t\t";
         textcolor(RED+BLINK);
         cprintf("NO NODE AVAILABLE FOR DISPLAY OPERATION..!!!");
         textcolor(WHITE);

       }
       else
       {
        temp=first;

          while(temp!=head)
          {

         cout<<"\n\n\t\t";
         //cout<<i;
         cout<<"  ";
         cout<<temp->info;

         temp=temp->next;

        }

       }
        cout<<"\n\t\t ";
       getch();
       break;

    case 0:  cout<<"\n\t\t";
         textcolor(RED+BLINK);
         cprintf("PRESS ANY KEY TO EXIT..!!!");
         textcolor(WHITE);
         getch();
         exit(0);
      default:
          cout<<"\n\t\t";
          textcolor(RED+BLINK);
          cprintf("INVALID CHOICE..!!!");
          textcolor(WHITE);
          getch();

    }
 }while(choice!=0);
 }

Friday, 22 March 2013

Command line argument in Java

/**
   * How to use command line arguments in java program.
   */
   class CmndLineArguments {

  public static void main(String[] args) {
    int length = args.length;
    if (length <= 0) {
    System.out.println("You need to enter some arguments.");
    }
   for (int i = 0; i < length; i++) {
    System.out.println(args[i]);
   }
   }
   }

Print Hello in Java

// Example by Dx panchal
 
public class HelloWorld {

 
    public static void main (String[] args) 
     {
 System.out.println ("Hello World!");
    }
}
 
 

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...