Code For Printing ASCII Table in C++

#include<iostream>
using namespace std;
void main()
{
for(int b=0;b<=255;b++)
{
cout<<"<<< Character >>> "<<(char)b<<" <<<No In Ascii Table >>> "<<b<<endl;
}
system("pause");
}

Student Database Software Code For C++

#include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
class student
{
private:
int id;
char name[30];
char age[20];
char address[150];
char phone[20];
char qual[100];
char db[100];
public:
void getdata()
{
cout<<"Enter Student ID: ";
cin>>id;
cin.ignore();
cout<<"\nEnter Student Name: ";
gets_s(name);
cin.ignore();
cout<<"Enter Student Address: ";
gets_s(address);
cin.ignore();
cout<<"Enter Student Ph#: ";
gets_s(phone);
cin.ignore();
cout<<"Enter Student Age: ";
gets_s(age);
cin.ignore();
cout<<"Enter Student Qualification: ";
gets_s(qual);
cin.ignore();
cout<<"Enter Student Date Of Birth: ";
gets_s(db);
cin.ignore();
}
void showdata()
{
cout<<"\nID: "<<id<<endl;
cout<<"\nName: "<<name<<endl;
cout<<"\nAddress :"<<address<<endl;
cout<<"\nPh#: "<<phone<<endl;
cout<<"\nAge: "<<age<<endl;
cout<<"\nQualification: "<<qual<<endl;
cout<<"\nDate Of Birth: "<<db<<endl;
cout<<""<<endl;
}
int rtrnid()
{
return id;
}
};
void write_data()
{
          student a;
          ofstream fout;
 fout.open("d:\\student.dat",ios::binary|ios::app);
          a.getdata();
          fout.write((char*)&a,sizeof(a));
          fout.close();
}
void search (int n)
{
          student a;
          ifstream fin;
 fin.open("D:\\student.dat",ios::binary);
          while(fin.read((char*)&a,sizeof(a)))
          {
                     if(a.rtrnid()==n)
{
cout<<"\nRecord For ID "<<n<<" Is Given Below\n ";
a.showdata();
break;
}
          }
          fin.close();
}
void del(int n)
{
          student a;
          ifstream fin;
 fin.open("D:\\student.dat",ios::in|ios::binary);
          ofstream fout;
 fout.open("D:\\temp.dat",ios::out|ios::binary);
          while(fin.read((char*)&a,sizeof(a)))
          {
                      if(a.rtrnid()!=n)
 {
                      fout.write((char*)&a,sizeof(a));
 break;
 }
 fin.read((char*)&a,sizeof(a));
          }
          fin.close();
          fout.close();
 remove("D:\\student.dat");
 rename("D:\\temp.dat","D:\\student.dat");
}
void modify(int n)
{
          fstream fout;
          student a;
          int found=0,cnt=0;
 fout.open("d:\\student.dat",ios::ate|ios::in|ios::out|ios::binary);
 fout.seekg(0,ios::beg);
          while( fout.read((char*)&a,sizeof(a)))
          {cnt++;
                if(a.rtrnid()==n)
                     {
                             found=1;
a.showdata();break;
                    }
 }
 if(found)
 {
 cout<<"\nModify Above Record: "<<endl;

 fout.seekp((cnt-1)* sizeof(a));
  a.getdata();
                              fout.write((char*)&a,sizeof(a));
 cout<<"\nRecord Has Been Successfully Updated\n";
                             
 }
 else  cout<<"Record Not found";
          fout.close();
}
void main()
{
int opt;
while(1)
{
system("CLS");
cout<<"====================="<<endl;
cout<<": Students Database :"<<endl;
cout<<"====================="<<endl;
cout<<""<<endl;
cout<<"<<<<< MAIN MENU >>>>>"<<endl;
cout<<""<<endl;
cout<<"1.Enter New Student Data"<<endl;
cout<<"2.Search Student Data"<<endl;
cout<<"3.Delete Student Data"<<endl;
cout<<"4.Modify Student Data"<<endl;
cout<<"0.Exit"<<endl;
cout<<"Enter your Option : ";
cin>>opt;
switch(opt)
{
case 1:
{
system("CLS");
cout<<"<<< NEW STUDENT ENTRY >>>"<<endl;
cout<<""<<endl;
write_data();
cout<<"\nYour Data Has Been Recoded\n";
cout<<"\nPress Any Key For Main Menu";
getch();
break;
}
case 2:
{
system("CLS");
cout<<"<<< STUDNET SEARCH >>>"<<endl;
cout<<""<<endl;
int n;
cout<<"Enter Student ID to Search Record: ";
cin>>n;
search(n);
cout<<"\nPress Any Key For Main Menu";
getch();
break;
}
case 3:
{
system("CLS");
cout<<"DELETE STUDENT RECORD"<<endl;
cout<<""<<endl;
int b;
cout<<"Enter Student ID You Want To Delete: "<<endl;
cin>>b;
del(b);
cout<<"\nRecord of "<<b<<" Has been Deleted"<<endl;
cout<<"\nPress Any Key For Main Menu";
getch();
break;
}
case 4:
{
system("CLS");
cout<<"MODIFY STUDENT RECORD"<<endl;
cout<<""<<endl;
int b;
cout<<"Enter Student ID To Modify RECORD: "<<endl;
cin>>b;
modify(b);
cout<<"\nPress Any Key For Main Menu";
getch();
break;
}
case 0:
{
exit(0);
}
default:
{
cout<<""<<endl;
cout<<"Invalid Input"<<endl;
cout<<""<<endl;
}
}
}
system ("pause");
}

A SIMPLE CALCULATOR CODE FOR C++

CALCULATOR CODE


#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
char ans='y';
while (ans=='y' || ans== 'Y')
{
float a,b,c,d;
double pi=3.14159265;
cout<<"                      <<@ Calculator By Hashmat naqvi @>>"<<endl;
cout<<" Press 1 for Addition"<<endl;
cout<<" Press 2 for Subtrection"<<endl;
cout<<" Press 3 for Division"<<endl;
cout<<" Press 4 for Multiplication"<<endl;
cout<<" Press 5 for Square"<<endl;
cout<<" Press 6 for Compairing Numbers"<<endl;
cout<<" Press 7 for Grades Calculator"<<endl;
cout<<" Press 8 for Cube"<<endl;
cout<<" Press 9 For Square Root"<<endl;
cout<<" press 0 For Exit"<<endl;
cout<<" Enter Your Choice : ";
cin>>c;
if (c==1)
{
cout<<"                                  ADDITION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a+b<<endl;
}
else if (c==2)
{
cout<<"                                 SUBRRECTION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a-b<<endl;
}
else if (c==3)
{
cout<<"                                  DIVISION:"<<endl;
cout<<" Enter 1st Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a/b<<endl;
}
else if (c==4)
{
cout<<"                                MULTIPLICATION:"<<endl;
cout<<" Enter 1nd Number:"<<endl;
cin>>a;
cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Result Is:"<<a*b<<endl;
}
else if (c==5)
{
cout<<"                                    SQUARE:"<<endl;
cout<<" Enter Number:"<<endl;
cin>>a;
cout<<" Result is:"<<a*a<<endl;
}
else if (c==6)
{
cout<<"                              COMPAIRING NUMBERS"<<endl;
cout<<" Enter 1st Number:"<<endl;
   cin>>a;
   cout<<" Enter 2nd Number:"<<endl;
cin>>b;
cout<<" Enter 3rd Number:"<<endl;
cin>>d;
if (a>b&&a>d)
{
cout<<" 1st Number Is Greater"<<endl;
}
else if (b>a&&b>d)
{
cout<<" 2nd Number Is Greater"<<endl;
}
else
{
cout<<" 3rd Number Is Greater"<<endl;
}
}
else if (c==7)
{
cout<<"                               GRADES CALCULATOR"<<endl;
cout<<" Enter your Marks Percentage:"<<endl;
cin>>a;
if (a<60)
{
   cout<<" You are Fail : Work Hard & Try Again"<<endl;
}
   else if (a<68)
{
   cout<<" You get C : Work Hard"<<endl;
}
   else if (a<76)
{
   cout<<" You Get C+ : Good"<<endl;
}
   else if (a<83)
{
   cout<<" You Get B : V.Good"<<endl;
}
   else if (a<89)
{
   cout<<" You Get B+ : Great"<<endl;
}
   else if (a<=100)
{
   cout<<" You Get A : Excellent"<<endl;
}
   else

{
   cout<<" INVALID INPUT"<<endl;
}
}
else if (c==8)
{
cout<<"                                     CUBE"<<endl;
cout<<" Enter Number"<<endl;
cin>>a;
cout<<" Result="<<a*a*a<<endl;
}
else if (c==9)
{
cout<<"                                  SQUARE ROOT"<<endl;
cout<<" Enter Number"<<endl;
cin>>a;
cout<<" Result is="<<sqrt (a)<<endl;
}
else if (c==0)
{
cout<<"                                   Bye Bye"<<endl;
}

else
{
cout<<" INVALID INPUT"<<endl;
}
{
cout<<"                        THANKS FOR USING MY CALCULATOR"<<endl;
cout<<"                                 See You Soon"<<endl;
}
cout<<"Do YOu want to Continue or recalculate Yes(Y),No (N)";
        cin>>ans;
}
system ("pause");
return 0;
}