programming
Wednesday, January 12, 2011
Linux kernel Module programming
Kernel modules help you to add or remove pieces of codes on demand.The modules extend the abilities of kernel without a reboot.
Friday, December 24, 2010
Orkut badges..
Hi all we all know about orkut badges they are gifts from google for best and hard working googlers
here i have some code to add badge to ur profile:
for :
here i have some code to add badge to ur profile:
for :
Happy Holidays!
Redeem code:- HOH0HO
for:
Happy New Year!
Redeem code:- FELIZ ANO NOV0
Tuesday, December 14, 2010
Program to find odd and even numbers by using commandline arguments...
# include <iostream.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>
void main(int argc,char **argv)
{
int *a=new int[argc];
int even[10],j=0,odd[10],k=0,temp;
for(int i=1;i<argc;i++)
{
char *ar=argv[i];
temp=0;
for(int m=0;m<strlen(ar);m++)
{temp=(temp*10)+ar[m]-48;}
a[i-1]=temp;
}
for(i=0;i<argc-1;i++)
if(a[i]%2==0)
{
even[j]=a[i];
j++;
}
else
{
odd[k]=a[i];
k++;}
cout<<"\nEven no.s\n";
for(i=0;i<j;i++)
cout<<even[i]<<" "<<endl;
cout<<"\nOdd numbers\n";
for(i=0;i<k;i++)
cout<<odd[i]<<" "<<endl;
getch();}
Intel Core i7 950 3.06GHz 8M L3 Cache LGA1366 Desktop Processor
# include <conio.h>
# include <stdlib.h>
# include <string.h>
void main(int argc,char **argv)
{
int *a=new int[argc];
int even[10],j=0,odd[10],k=0,temp;
for(int i=1;i<argc;i++)
{
char *ar=argv[i];
temp=0;
for(int m=0;m<strlen(ar);m++)
{temp=(temp*10)+ar[m]-48;}
a[i-1]=temp;
}
for(i=0;i<argc-1;i++)
if(a[i]%2==0)
{
even[j]=a[i];
j++;
}
else
{
odd[k]=a[i];
k++;}
cout<<"\nEven no.s\n";
for(i=0;i<j;i++)
cout<<even[i]<<" "<<endl;
cout<<"\nOdd numbers\n";
for(i=0;i<k;i++)
cout<<odd[i]<<" "<<endl;
getch();}
Intel Core i7 950 3.06GHz 8M L3 Cache LGA1366 Desktop Processor
Monday, December 13, 2010
Program to perform all array operations
//Program to perform all array operations # include <iostream.h>
# include <conio.h>
int main()
{
clrscr();
int *a,n;
cout<<"Enter total no. of Elements\n";
cin>>n;
a=new int[n];
int opt;
int no=0;
do
{
clrscr();
cout<<"\n\t\t\t*****Menu*****\n\t1:Add\n\t2:Delete\n\t3:Search\n\t4:Sort\n\t5:Merge\n\t6:Display\n\t7:Exit\n";
cin>>opt;
switch(opt)
{
case 1 :
int op;
clrscr();
A : cout<<"\n1:Begin\n2:End\n3:Specific location\n";
cin>>op;
switch(op)
{
case 1:
int n1;
cout<<"Enter a no"<<endl;
cin>>n1;
if(no==0)
{
a[no]=n1;
no++;
}
else
{
if(no>=n)
{
cout<<"Not enough space...."<<endl;
}
else
{
for(int i=no;i>0;i--)
a[i]=a[i-1];
a[i]=n1;
no++;}
}
break;
case 2:
cout<<"Enter a no";
cin>>n1;
if(no==0)
{
a[no]=n1;
no++;
}
else
{
if(no>=n)
{
cout<<"Not enough space...."<<endl;
}
else{
a[no]=n1;
no++;}
}
break;
case 3 :
int pos;
cout<<"Enter a position\n";
cin>>pos;
cout<<pos<<" "<<no<<endl;
if(pos<no||pos>=n)
{
cout<<"Invalid location\n";
}
else
{
cout<<"Enter a no\n";
cin>>n1;
for(int i=no;i>=pos;i--)
a[i]=a[i-1];
a[i]=n1;
no++;
}
break;
}
char ch;
cout<<"Do u want to continue..(y/n)\n";
cin>>ch;
if(ch=='y')
goto A;
break;
case 2 :clrscr();
B : cout<<"\n1:Begin\n2:End\n3:Specific location\n";
cin>>op;
switch(op)
{
case 1 : if(no==0)
cout<<"Array is empty";
else
{
for(int i=0;i<no;i++)
a[i]=a[i+1];
no--;
}
break ;
case 2 : if(no==0)
cout<<"Array is empty";
else
no--;
break;
case 3 : int pos;
cout<<"Enter a position";
cin>>pos;
if((pos>=no)&&(no==0))
cout<<"Invalid operation";
else
{
for(int i=pos;i<no;i++)
a[i]=a[i+1];
no--;
}
break;
}
cout<<"Do u want to continue..(y/n)\n";
cin>>ch;
if(ch=='y')
goto B;
break;
case 3 : clrscr();
int item,flag=0;
cout<<"Enter an item";
cin>>item;
cout<<"\n1:Binary search\n2:Linear search";
cin>>op;
switch(op)
{
case 1 : for(int i=0;i<no-1;i++)
{
for(int j=0;j<no-1-i;j++)
if(a[j]>a[j+1])
{
int tem=a[j];
a[j]=a[j+1];
a[j+1]=tem;
}
}
int m,b=0,e=no;
while(b<=e)
{
m=(b+e)/2;
getch();
if(a[m]==item)
{
cout<<"Item present at:"<<m;
flag=1;
getch();
break;
}
else
{
if(a[m]>item)
{e=m-1;}
else
{ b=m+1;}
}
}
if(flag==0)
{
cout<<"Item not present\n";
getch();
}
break;
case 2 : int flag1=0;
for( i=0;i<no;i++)
{
if(a[i]==item)
{
flag1=1;
break;}
}
if(flag1==0)
{
cout<<"Item not present....";
getch();
}
else
{
cout<<"Item present at:"<<i;
getch();
}
break;
}
break;
case 4: clrscr();
int temp;
cout<<"\nEnter an option\n1:Bubble sort\n2:Selection sort\n";
cin>>op;
switch(op)
{
case 1: for(int i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
break;
case 2: int item,loc;
for(i=0;i<no;i++)
{
item=a[i];
loc=temp=i;
for(int j=i+1;j<no;j++)
{
if(a[j]>item)
{
item=a[j];
loc=j;
}
}
if(loc!=temp)
{
int t=a[loc];
a[loc]=a[temp];
a[temp]=t;
}
}
}
break;
case 5:clrscr();
cout<<"\nEnter an option\n1:General maerge\n2:Merge in sorted order\n3:Merge without any repeating elements\n4:Merge in sorted order without any repeating elements\n";
cin>>op;
switch(op)
{
case 1:clrscr();
int *b=new int[5+(no-1)];
cout<<"\nEnter 5 elements\n";
for(int i=0;i<5;i++)
cin>>b[i];
for(int j=0;j<no;j++,i++)
b[i]=a[j];
cout<<"\nNew array\n";
for(i=0;i<(5+(no-1));i++)
cout<<b[i]<<" ";
getch();
break;
case 2:clrscr();
int idx=5;
int *c=new int[5+(no-1)];
cout<<"\nEnter 5 elements\n";
for(i=0;i<5;i++)
cin>>b[i];
for(i=0;i<5;i++)
{
for(int j=0;j<5-1;j++)
if(b[i]>b[j])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
int k=0,l=0,mz=0;
while(k!=no&l!=idx)
{
if(a[k]>=b[l])
{
c[mz]=a[k];
k++;
}
else
{
c[mz]=b[l];
l++;
}
mz++;
}
while(k!=no)
{
c[mz]=a[k];
k++;mz++;
}
while(l!=idx)
{
c[mz]=b[l];
mz++;
l++;
}
for(int p=0;p<mz;p++)
cout<<c[p]<<" ";
getch();
break;
case 3:clrscr();
int *ch=new int[5];
cout<<"\nEnter 5 elements\n";
for( i=0;i<5;i++)
cin>>ch[i];
int skip=-100;
for(i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
if(ch[i]==ch[j])
ch[i]=skip++; }
}
for(i=0;i<no;i++)
{
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
a[i]=skip++; }
}
int *na=new int[5+no];
l=0,k=0,i=0;
while(l!=5)
{
if(ch[l]>0)
{
na[i]=ch[l];
i++;
}
l++;
}
while(k!=no)
{
if(a[k]>0)
{
na[i]=a[k];
i++;
}
k++;
}
for(i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
if(na[i]==na[j])
na[i]=skip++; }
}
for(int d=0;d<i;d++)
if(na[i]>0)
cout<<na[d]<<" ";
getch();
break;
case 4: clrscr();
int *f=new int[5];
int index=5;
cout<<"\nEnter 5 elements\n";
for(i=0;i<5;i++)
cin>>f[i];
for(i=0;i<index;i++)
{
for(int j=0;j<i;j++)
{
if(f[i]==f[j])
{ for(int y=i;y<index;y++)
f[y]=f[y+1];
index--;}
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
{ for(int y=i;y<no;y++)
a[y]=a[y+1];
no--;}
}
}
for(i=0;i<index;i++)
{
for(int j=0;j<index-1;j++)
if(f[i]>f[j])
{
temp=f[i];
f[i]=f[j];
f[j]=temp;
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
int total=index+no;
int *cl=new int[total];
k=0,l=0,mz=0;
while(k!=no&l!=index)
{
if(a[k]>=f[l])
{
cl[mz]=a[k];
k++;
}
else
{
cl[mz]=f[l];
l++;
}
mz++;
}
while(k!=no)
{
cl[mz]=a[k];
k++;mz++;
}
while(l!=index)
{
cout<<"\nwhile:3"<<f[l];
getch();
cl[mz]=f[l];
mz++;
l++;
}
for(i=0;i<mz;i++)
{
for(int j=0;j<i;j++)
{
if(cl[i]==cl[j])
{ for(int y=i;y<mz;y++)
cl[y]=cl[y+1];
mz--;}
}
}
for(i=0;i<mz;i++)
cout<<cl[i]<<" ";
getch();
break;
}
break;
case 6:clrscr();
for(int i=0;i<no;i++)
{
cout<<a[i]<<"\t";
}
getch();
break;
case 7 : return 0;
}
}while(1);
}
The Complete Guide for CPP Examination Preparation
Thinking in C++: Introduction to Standard C++, Volume One (2nd Edition) (Vol 1)C++ : The Complete Reference, 4th EditionC++: The Complete Reference, 4th Edition
# include <conio.h>
int main()
{
clrscr();
int *a,n;
cout<<"Enter total no. of Elements\n";
cin>>n;
a=new int[n];
int opt;
int no=0;
do
{
clrscr();
cout<<"\n\t\t\t*****Menu*****\n\t1:Add\n\t2:Delete\n\t3:Search\n\t4:Sort\n\t5:Merge\n\t6:Display\n\t7:Exit\n";
cin>>opt;
switch(opt)
{
case 1 :
int op;
clrscr();
A : cout<<"\n1:Begin\n2:End\n3:Specific location\n";
cin>>op;
switch(op)
{
case 1:
int n1;
cout<<"Enter a no"<<endl;
cin>>n1;
if(no==0)
{
a[no]=n1;
no++;
}
else
{
if(no>=n)
{
cout<<"Not enough space...."<<endl;
}
else
{
for(int i=no;i>0;i--)
a[i]=a[i-1];
a[i]=n1;
no++;}
}
break;
case 2:
cout<<"Enter a no";
cin>>n1;
if(no==0)
{
a[no]=n1;
no++;
}
else
{
if(no>=n)
{
cout<<"Not enough space...."<<endl;
}
else{
a[no]=n1;
no++;}
}
break;
case 3 :
int pos;
cout<<"Enter a position\n";
cin>>pos;
cout<<pos<<" "<<no<<endl;
if(pos<no||pos>=n)
{
cout<<"Invalid location\n";
}
else
{
cout<<"Enter a no\n";
cin>>n1;
for(int i=no;i>=pos;i--)
a[i]=a[i-1];
a[i]=n1;
no++;
}
break;
}
char ch;
cout<<"Do u want to continue..(y/n)\n";
cin>>ch;
if(ch=='y')
goto A;
break;
case 2 :clrscr();
B : cout<<"\n1:Begin\n2:End\n3:Specific location\n";
cin>>op;
switch(op)
{
case 1 : if(no==0)
cout<<"Array is empty";
else
{
for(int i=0;i<no;i++)
a[i]=a[i+1];
no--;
}
break ;
case 2 : if(no==0)
cout<<"Array is empty";
else
no--;
break;
case 3 : int pos;
cout<<"Enter a position";
cin>>pos;
if((pos>=no)&&(no==0))
cout<<"Invalid operation";
else
{
for(int i=pos;i<no;i++)
a[i]=a[i+1];
no--;
}
break;
}
cout<<"Do u want to continue..(y/n)\n";
cin>>ch;
if(ch=='y')
goto B;
break;
case 3 : clrscr();
int item,flag=0;
cout<<"Enter an item";
cin>>item;
cout<<"\n1:Binary search\n2:Linear search";
cin>>op;
switch(op)
{
case 1 : for(int i=0;i<no-1;i++)
{
for(int j=0;j<no-1-i;j++)
if(a[j]>a[j+1])
{
int tem=a[j];
a[j]=a[j+1];
a[j+1]=tem;
}
}
int m,b=0,e=no;
while(b<=e)
{
m=(b+e)/2;
getch();
if(a[m]==item)
{
cout<<"Item present at:"<<m;
flag=1;
getch();
break;
}
else
{
if(a[m]>item)
{e=m-1;}
else
{ b=m+1;}
}
}
if(flag==0)
{
cout<<"Item not present\n";
getch();
}
break;
case 2 : int flag1=0;
for( i=0;i<no;i++)
{
if(a[i]==item)
{
flag1=1;
break;}
}
if(flag1==0)
{
cout<<"Item not present....";
getch();
}
else
{
cout<<"Item present at:"<<i;
getch();
}
break;
}
break;
case 4: clrscr();
int temp;
cout<<"\nEnter an option\n1:Bubble sort\n2:Selection sort\n";
cin>>op;
switch(op)
{
case 1: for(int i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
break;
case 2: int item,loc;
for(i=0;i<no;i++)
{
item=a[i];
loc=temp=i;
for(int j=i+1;j<no;j++)
{
if(a[j]>item)
{
item=a[j];
loc=j;
}
}
if(loc!=temp)
{
int t=a[loc];
a[loc]=a[temp];
a[temp]=t;
}
}
}
break;
case 5:clrscr();
cout<<"\nEnter an option\n1:General maerge\n2:Merge in sorted order\n3:Merge without any repeating elements\n4:Merge in sorted order without any repeating elements\n";
cin>>op;
switch(op)
{
case 1:clrscr();
int *b=new int[5+(no-1)];
cout<<"\nEnter 5 elements\n";
for(int i=0;i<5;i++)
cin>>b[i];
for(int j=0;j<no;j++,i++)
b[i]=a[j];
cout<<"\nNew array\n";
for(i=0;i<(5+(no-1));i++)
cout<<b[i]<<" ";
getch();
break;
case 2:clrscr();
int idx=5;
int *c=new int[5+(no-1)];
cout<<"\nEnter 5 elements\n";
for(i=0;i<5;i++)
cin>>b[i];
for(i=0;i<5;i++)
{
for(int j=0;j<5-1;j++)
if(b[i]>b[j])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
int k=0,l=0,mz=0;
while(k!=no&l!=idx)
{
if(a[k]>=b[l])
{
c[mz]=a[k];
k++;
}
else
{
c[mz]=b[l];
l++;
}
mz++;
}
while(k!=no)
{
c[mz]=a[k];
k++;mz++;
}
while(l!=idx)
{
c[mz]=b[l];
mz++;
l++;
}
for(int p=0;p<mz;p++)
cout<<c[p]<<" ";
getch();
break;
case 3:clrscr();
int *ch=new int[5];
cout<<"\nEnter 5 elements\n";
for( i=0;i<5;i++)
cin>>ch[i];
int skip=-100;
for(i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
if(ch[i]==ch[j])
ch[i]=skip++; }
}
for(i=0;i<no;i++)
{
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
a[i]=skip++; }
}
int *na=new int[5+no];
l=0,k=0,i=0;
while(l!=5)
{
if(ch[l]>0)
{
na[i]=ch[l];
i++;
}
l++;
}
while(k!=no)
{
if(a[k]>0)
{
na[i]=a[k];
i++;
}
k++;
}
for(i=0;i<5;i++)
{
for(int j=0;j<i;j++)
{
if(na[i]==na[j])
na[i]=skip++; }
}
for(int d=0;d<i;d++)
if(na[i]>0)
cout<<na[d]<<" ";
getch();
break;
case 4: clrscr();
int *f=new int[5];
int index=5;
cout<<"\nEnter 5 elements\n";
for(i=0;i<5;i++)
cin>>f[i];
for(i=0;i<index;i++)
{
for(int j=0;j<i;j++)
{
if(f[i]==f[j])
{ for(int y=i;y<index;y++)
f[y]=f[y+1];
index--;}
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<i;j++)
{
if(a[i]==a[j])
{ for(int y=i;y<no;y++)
a[y]=a[y+1];
no--;}
}
}
for(i=0;i<index;i++)
{
for(int j=0;j<index-1;j++)
if(f[i]>f[j])
{
temp=f[i];
f[i]=f[j];
f[j]=temp;
}
}
for(i=0;i<no;i++)
{
for(int j=0;j<no-1;j++)
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
int total=index+no;
int *cl=new int[total];
k=0,l=0,mz=0;
while(k!=no&l!=index)
{
if(a[k]>=f[l])
{
cl[mz]=a[k];
k++;
}
else
{
cl[mz]=f[l];
l++;
}
mz++;
}
while(k!=no)
{
cl[mz]=a[k];
k++;mz++;
}
while(l!=index)
{
cout<<"\nwhile:3"<<f[l];
getch();
cl[mz]=f[l];
mz++;
l++;
}
for(i=0;i<mz;i++)
{
for(int j=0;j<i;j++)
{
if(cl[i]==cl[j])
{ for(int y=i;y<mz;y++)
cl[y]=cl[y+1];
mz--;}
}
}
for(i=0;i<mz;i++)
cout<<cl[i]<<" ";
getch();
break;
}
break;
case 6:clrscr();
for(int i=0;i<no;i++)
{
cout<<a[i]<<"\t";
}
getch();
break;
case 7 : return 0;
}
}while(1);
}
The Complete Guide for CPP Examination Preparation
Thinking in C++: Introduction to Standard C++, Volume One (2nd Edition) (Vol 1)C++ : The Complete Reference, 4th EditionC++: The Complete Reference, 4th Edition
Sunday, December 12, 2010
About this blog
Hi it,z my debut to blogging via this cute blog i wish to deal with coding.i will more happy if we can code in a differ way than traditions let's talk and develop new ideas share books on programming help other earn knowledge
Subscribe to:
Posts (Atom)