Friday, April 2, 2010

I Have submitted some Programs to understand C#

STEP 1

   // A simple program to explain the structure of a C# program
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine(" FIRST STEP FOR A C# PROGRAM");
            Console.ReadLine();
        }
    }

* This is purely Object Oriented approach so everything must me contained in a class.
* Like the header files, here we have namespaces. Here System is a namespace and Console is a class  
   contained in that namespace. Writeline is function to display the output.
* We dont have function like getch() to make the cursor wait at the output screen. Instead of that we can  
   give the statement  Console.ReadLine();
* Again ReadLine() is a function in console class.

FRIENDSHIP


Friendship is always kind and patient.It is never jealous.
Rude at the times of bad things.
It does not have fence.
It is always a pleasure.
It is always ready to excuse whatever done, to hope till last breathe and into endeavour.

Friends are those who remebers the song in your heart and reminds you the lyrics when you forget it.

Dont ever miss such friends.

For all my dear friends

Sunday, March 21, 2010

A Program to find the grade of a student in C++


main()
{
 struct student
 {
  int reg_no,m1,m2,m3,total,avg;
  char *name;
 }stud[10];
 int i;
 clrscr();
 for(i=1;i<=1;i++)
 {
  cout<<"\nENTER THE REG_NO,NAME,M1,M2,M3 : ";
  cin>>stud[i].reg_no>>stud[i].name>>stud[i].m1>>stud[i].m2>>stud[i].m3;
 }
 for(i=1;i<=1;i++)
 {
  cout<<"\n REG_NO  : "<<<"\n NAME    : "<<<"\n M1      : "<<<"\n M2      : "<<<"\n M3      : "<
  stud[i].total = stud[i].m1+stud[i].m2+stud[i].m3;
  stud[i].avg = stud[i].total/3;
  cout<<"\n TOTAL   : "<<<"\n AVERAGE : "<
  if((stud[i].m1<50 || stud[i].m2<50 || stud[i].m3<50))
  {
   cout<<"\n RESULT  : FAIL"<
  }
  else
  {
   cout<<"\n RESULT  : PASS"<
  }
  if(stud[i].avg>90)
  {
   cout<<"\n GRADE   : OUTSTANDING";
  }
  else if(stud[i].avg>75 && stud[i].avg <90)
  {
   cout<<"\n GRADE   : FIRST CLASS";
  }
  else if(stud[i].avg>60 && stud[i].avg<75)
  {
   cout<<"\n GRADE   : SECOND CLASS";
  }
  else if(stud[i].avg>50 && stud[i].avg<60)
  {
   cout<<"\n GRADE   : THIRD CLASS";
  }
  else
  {
   cout<<"\n GRADE   : NIL";
  }
 }
 getch();
 return 0;
}

Name of this program - SACHIN. To find the batsman details such as strike rate, average etc etc

main()
{
 long runs[10],inn[10],not_out[10],tot[10],ball[10];
 long double avg[10];
 long double strk[10];
 char name[10][10];
 clrscr();
 cout<<"\n~~~~~~~~~~~~~~~ENTER THE DETAILS OF THE PLAYERS~~~~~~~~~~~~~~";
 for(int i=1;i<=1;i++)
 {
  cout<<"\n ENTER THE NAME : ";
  cin>>name[i];
  cout<<"\n NO OF MATCHES PLAYED : ";
  cin>>inn[i];
  cout<<"\n ENTER THE TOTAL RUNS SCORED : ";
  cin>>runs[i];
  cout<<"\n NUMBER OF BALLS FACED : ";
  cin>>ball[i];
  cout<<"\n NO OF TIMES NOT OUT : ";
  cin>>not_out[i];
 }
 for(i=1;i<=1;i++)
 {
  tot[i]  = inn[i]-not_out[i];
  if(inn[i]==not_out[i])
  {
   avg[i] = runs[i];
  }
  else
  {
   avg[i]  = runs[i]/tot[i];
  }
   strk[i] = (runs[i]*100)/ball[i];
  }
 for(i=1;i<=1;i++)
 {
  cout<<"\n NAMES"<<"   INNINGS"<<"       RUNS"<<"       NOT OUT"<<"      AVG"<<"      STRIKE RATE";
  cout<<"\n"<<<"\t     "<<<"\t"<<<"\t     "<<<"\t"<<<"\t   "<
 }
  getch();
  return 0;
}

A C++ PROGRAM TO FIND WHEHTHER THE GIVEN NUMBER IS PRIME OR NOT

void main()
{
 clrscr();
 int num,i,c;
 cout<<"PROGRAM TO FIND THE PRIME NUMBER";
 cout<<"\nENTER THE NUMBER : ";
 cin>>num;
 if(num==1)
 {
  cout<<"THE GIVEN NUMBER IS A PRIME NUMBER";
 }

 for(i=2;i<=num-1;i++)
 {
  if(num%i == 0)
  {
   cout<<"THE GIVEN NUMBER IS NOT A PRIME NUMBER";
   break;
  }
 }
  if(i==num)
  {
   cout<<"THE GIVEN NUMBER IS A PRIME NUMBER";
  }
 getch();
}

A PROGRAM TO FIND THE BIGGER NUMBER OF THE GIVEN SERIES

void main()
{
 int i,n,a[150],max;
 clrscr();
 cout<<"ENTER THE LIMIT : ";
 cin>>n;
 cout<<"ENTER THE ELEMENTS : ";
 for(i=1;i<=n;i++)
 {
  cin>>a[i];
 }
 max = a[1];
 for(i=1;i<=n;i++)
  {
   if(a[i]>max)
   {
    max = a[i];
   }
  }
  cout<<"\nTHE BIGGEST NUMBER IS : "<<
  getch();
}

A C++ PROGRAM TO COMPARE TWO STRINGS WITHOUT USING strcmp() FUNCTION

main()
{
 clrscr();
 char a[25],b[25];
 int cnt=1,i=1;
 cout<<"\n ENTER THE STRING 1 : ";
 cin>>a;
 cout<<"\n ENTER THE STRING 2 : ";
 cin>>b;

 while(a[i]!='\0' && b[i]!='\0')
 {
  if(a[i]==b[i])
  {
   cnt++;
  }
  else
  {
   cout<<"\n\n THE TWO STRINGS ARE NOT EQUAL";
  }
  i++;
 }

 if(i==cnt)
 {
  int n;
  clrscr();
  cout<<"\n\n\t\t~~~~~~~~~~COMPARISON RESULT~~~~~~~~~~~";
  cout<<"\n\n THE GIVEN TWO STRINGS ARE ONE & SAME ";
 }

 getch();
 return 0;
}

Saturday, March 13, 2010

A C++ PROGRAM FOR FLAMES - A love GAME To Find whether your partner's relation is your Friend or Love Or Affection or Marriage Or Enemy Or Sister



include
#include
#include
#include
void main()
{
 char a[100],b[100],m='#',n='#',o='\0';
 int i=0,j=0,size,k;
 int cnt=0,cnt1=0;
 char *r,flag='y';
 clrscr();
 while(flag == 'y' || flag=='Y')
 {
 cout<<"\n\t DILLU IRUNDHA TRY PANNU MA..!!! ";
 cout<<"\n ENTER YOUR NAME  : ";
 cin>>a;

 cout<<"\n ENTER YOUR PARTNER'S NAME : ";
 cin>>b;

 size = (strlen(a)+strlen(b));

 for(i=0;a[i]!='\0';i++)
 {
  for(j=0;b[j]!='\0';j++)
  {
   if(a[i]==b[j])
   {
    size=size-2;
    break;
   }}}
 for(i=0;a[i]!='\0';i++)
 {
  for(j=i+1;a[j]!='\0';j++)
  {
   if(a[i]==a[j])
   {
    cnt = cnt+1;
    m = a[i];
   }}}
 for(i=0;b[i]!='\0';i++)
 {
  for(j=i+1;b[j]!='\0';j++)
  {
   if(b[i]==b[j])
   {
    cnt1 = cnt1+1;
    n = b[i];
   }}}
 for(i=0;b[i]!='\0';i++)
 {
  if(b[i] == m)
  {
   o=b[i];
  }}

 //cout<<"\n"<<<"\n"<<<"\n"<<
 //cout<<<<<"\n"<

 if(cnt == cnt1-1)
 {
  size = size;
 }

 else if(m!=n && cnt==0 && cnt1==1)
 {
  size = size;
 }

 else if(cnt==cnt1 && m==n)
 {
  size = size;
 }

 else if(cnt == cnt1 && m!=n && m==o)
 {
  size = size+2;
 }

 else if((cnt1 == cnt-2 || cnt == cnt1-2) && m==n && n!=o)
 {
  size = size+2;
 }

 else if(m!=n && cnt==0 && cnt1==0)
 {
  size = size;
 }

 else if(cnt == cnt-1 && m==n)
 {
  size = size;
 }

 else if(cnt%2!=0 && cnt1%2!=0 && m==n && m!=o)
 {
  size = size+2;
 }

 else if(cnt%2!=0 && cnt1%2!=0 && m!=n && cnt1!=1)
 {
  size = size+2;
 }

 else if(cnt1 == cnt-2 && m!=n && o==m)
 {
  size = size+4;
 }

 else if(m==n && cnt%2!=0 && cnt1%2!=0 && m!=o)
 {
  size = size;
 }

 else if(m==n && cnt1%2!=0 && o==m && cnt%2!=0)
 {
  size = size+9;
 }
  else if(m==n && n==o && cnt==cnt1/2)
 {
  size = size;
 }

 else
 {
  for(i=0;a[i]!='\0';i++)
  {
   for(j=1;a[j]!='\0';j++)
   {
    if(a[i]==a[j])
    {
     if(b[i] == a[i])
     {
      size = size+2;
      break;
     }}}}}

 switch(size)
 {
  case 1 :
  cout<<"\n\t ***~~~NO SPECIAL RELATION BETWEEN YOU AND YOUR PARTNER~~~***\n\t\t\t    !!! SORRY!!!";
  break;
  case 2 :
  r="E";
  break;
  case 3 :
  r="F";
  break;
  case 4 :
  r ="E";
  break;
  case 5 :
  r = "F";
  break;
  case 6 :
  r = "M";
  break;
  case 7 :
  r = "E";
  break;
  case 8 :
  r = "A";
  break;
  case 9 :
  r = "E";
  break;
  case 10 :
  r = "L";
  break;
  case 11 :
  r = "M";
  break;
  case 12 :
  r = "A";
  break;
  case 13 :
  r = "A";
  break;
  case 14 :
  r = "F";
  break;
  case 15 :
  r = "M";
  break;
  case 16 :
  r = "F";
  break;
  case 17 :
  r = "A";
  break;
  case 18 :
  r = "F";
  break;
  case 19 :
  r = "L";
  break;
  case 20 :
  r = "E";
  break;
  case 21:
  r = "F";
  break;
  case 22:
  r = "E";
  break;
  default :
  cout<<"\n\t ~~~ EVERYTHING IS BETWEEN YOU AND YOUR PARTNER ~~~ ";
  break;
 }
 cout<<"\n THE REMAINING CHARACTER IS '"<<<"' SO,";
 if(*r=='F')
 {
  cout<<"\n\n\t !!!!!!!! YOU BOTH ARE GOOD FRIENDS !!!!!!!!";
 }
 else if(*r=='L')
 {
  cout<<"\n\n\t !!!!!!@!!!!!! YOU BOTH ARE LOVERS !!!!!!@!!!!!!";
 }
 else if(*r=='M')
 {
  cout<<"\n\n\t !!!!!!!! YOU BOTH WILL MARRY EACH OTHER !!!!\b!!!!";
  cout<<"\n\n WARNING : DONT TRY TO MARRY IF YOU BOTH ARE SAME GENDER";
 }
 else if(*r=='A')
 {
  cout<<"\n\n\t ###### YOU BOTH HAVE MORE AFFECTION ON EACH OTHER ######";
 }
 else if(*r=='E')
 {
  cout<<"\n\n\t ****** YOU BOTH ARE ENEMIES ******";
 }
 else if(*r=='S')
 {
  cout<<"\n\n\t $$$$$$ SHE IS YOUR SISTER.IF THE PARTNER IS MALE THEN HE IS YOUR BROTHER $$$$$$";
 }
 /*else
 {
   cout<<"\n\n\t &&&&&& YOU ARE LIKE EVERYTHING TO HER &&&&&&";
 }*/
 cout<<"\n DO YOU WANT TO TEST AGAIN (Y/N) : ";
 flag = getch();
 clrscr();
}
}