Tuesday 9 December 2014

1. Create a class named weather report that holds a daily weather report with data members day_of_month,hightemp,lowtemp,amount_rain and amount_snow. The constructor initializes the fields with default values: 99 for day_of_month, 999 for hightemp,-999 for low emp and 0 for amount_rain and amount_snow. Include a function that prompts the user and sets values for each field so that you can override the default values. Write a C++/Java/Python program that creates a monthly report. a) Menu driven program with options to Enter data and Display report b) Report Format


/*Problem Statement: 

Create a class named weather report that holds a daily weather report with data members day_of_month,hightemp,lowtemp,amount_rain and amount_snow. The constructor initializes the fields with default values: 99 for day_of_month, 999 for hightemp,-999 for low emp and 0 for amount_rain and amount_snow. Include a function that prompts the user and sets values for each field so that you can override the default values. Write a C++/Java/Python program that creates a monthly report.
a) Menu driven program with options to Enter data and Display report
b) Report Format

*/

#include<iostream>
using namespace std;
class weather
{
    int d_o_m;
    float htemp,ltemp,amt_of_rain,amt_of_snow;
public:
    weather();
    void inputdata(int);
    void display();
    void average(weather *w);
};
weather::weather()
{
       htemp=999;
    ltemp=-999;
    amt_of_rain=0;
    amt_of_snow=0;
    d_o_m=99;
}
void weather::inputdata(int d)
{
    d_o_m=d;
    cout<<"Enter high Temp:";
    cin>>htemp;
    cout<<"\nEnter low Temp:";
    cin>>ltemp;
    cout<<"\nEnter Amt of Rain:";
    cin>>amt_of_rain;
    cout<<"\nEnter Amt of Snow:";
    cin>>amt_of_snow;
}
void weather::display()
{
         cout<<"\t"<<d_o_m;
     cout<<"\t\t"<<htemp;
     cout<<"\t"<<ltemp;
     cout<<"\t"<<amt_of_rain;
     cout<<"\t"<<amt_of_snow;
}
void weather::average(weather w[31])
{
    int train,tsnow,tltemp,thtemp;
    float avghtemp,avgltemp,avgrain,avgsnow;
    train=tsnow=tltemp=thtemp=0;
    int i,count=0;
    for(i=1;i<=31;i++)
    {
          if(w[i].d_o_m==90)
        continue;
        else
        {
          thtemp+=w[i].htemp;
        tltemp+=w[i].ltemp;
        train+=w[i].amt_of_rain;
        tsnow+=w[i].amt_of_snow;
        count++;
        }
    }
avghtemp=thtemp/count;
avgltemp=tltemp/count;
avgrain=train/count;
avgsnow=tsnow/count;
cout<<"\nAverage High Temp:"<<avghtemp;
cout<<"\nAverage Low Temp:"<<avgltemp;
cout<<"\nAverage Amount of Rain:"<<avgrain;
cout<<"\nAverage Amount of Snow:"<<avgsnow;
}
int main()
{
  weather data[12][31],temp[31],obj;
  int ch,i,day,month;
  char ans;
cout<<"\nWEATHER REPORT";
do
{
cout<<"\n Main Menu";
cout<<"\n1.Enter Data.";
cout<<"\n2.Display Report.";
cout<<"\n3.Exit.";
cout<<"\nEnter your choice:";
cin>>ch;
switch(ch)
{
 case 1:
           cout<<"\nEnter the month:";
    cin>>month;
    cout<<"\nEnter the day:";
    cin>>day;
    data[month][day].inputdata(day);
    break;
 case 2:
    cout<<"\nEnter the month:";
    cin>>month;
    cout<<"\n\n\tDay\tDay_o_M\tAmt_Rain\tAmt_Snow\tHigh_temp\tLow_temp";
    for(int i=1;i<=31;i++)
    {
             cout<<"\n"<<i;
        data[month][i].display();
    }
    for(int i=1;i<=31;i++)
    {
        temp[i]=data[month][i];
    }
    obj.average(temp);
    break;
}
cout<<"\nDo u want to continue?";
cin>>ans;
}while(ans=='y');
return 0;
}

8. Create a C++ class named Television that has data members to hold the model number and the screen size in inches, and the price. Member functions include overloaded insertion and extraction operators. If more than four digits are entered for the model, if the screen size is smaller than 12 or greater than 70 inches, or if the price is negative or over $5000 then throw an integer. Write a main() function that instantiates a television object, allows user to enter data and displays the data members .If an exception is caught, replace all the data member values with zero values.


/* Problem Statement:

Create a C++ class named Television that has data members to hold the model number and the screen size in inches, and the price. Member functions include overloaded insertion and extraction operators. If more than four digits are entered for the model, if the screen size is smaller than 12 or greater than 70 inches, or if the price is negative or over $5000 then throw an integer. Write a main() function that instantiates a television object, allows user to enter data and displays the data members .If an exception is caught, replace all the data member values with zero values.


*/


/*  Television.cpp  */

#include<iostream>
#include<string.h>
Using namespace std;
Class television
{
    int price,e;
    float size                                                                  
    char model[20];
    public:
    friend istream &operator >>(istream &din,television &t)
    {
        cout<<"\n\n Enter model number of TV::";
        cin>>t.model;
        cout<<"\n\n Enter size of TV(Inches)::";                                                                               
        cin>>t.size;
        cout<<"\n\n Enter Price of TV::";
        cin>>t.price;
        return(din);
    }
    friend ostream &operator >>(oistream &dout,television &t)
    {
        try
        {
            if(strlen(t.model)>4)
            throw(1);
            if(t.size<12000)
            throw(2);
            if(t.size>70000)
            throw(3);
            if(t.price>50000)
            throw(4);
            else
            {
                cout<<"\n Model number of TV::"<<t.model;
                cout<<"\nSize of TV<<t.size;
                cout<<"\n Price of TV<<t.price;
            }
            catch(int e)
            {
                switch(e)
                {
                    case 1:
                        cout<<"\n Exception Caught";
                        cout<<"\n Model no should be less than 4 digits long!!!";
                    break;
                    case 2:
                        cout<<"\n Exception Caught";
                        cout<<"\nSize should be greater than 12 inches!!!";
                    break;
                    case 3:
                        cout<<"\n Exception Caught";
                        cout<<"\n Size should be less than 70 inches!!!";
                    break;
                    case 4:
                        cout<<"\n Exception Cauht";
                        cout<<"\n Price should be less than or equal to $5000!!!";
                    break;
                }
            }
            return(dout);
        }
    }
};   
void main()
{
    int ch;
    Television t1;
    cout<<"\n\t============Exception Handling===============\n";
    do
    {
        cout<<"\n\n\t 1.Insert data\n\t Display Data \n\t 3.Exit\n";
        cout<<"Enter your choice";
        cin>>ch;
        switch(ch)
        {
            case 1:
                cin>>t1;
            break;
            case 2:
                cout<<t2;
            break;
            case 3:
            break;
        default:
            cout<<"Enter correct choice";
        }
    }while(ch!=3);
    getch()
}

7. Design a C++ base class consisting of the data members such as name of the student, roll number and subject. The derived class consists of the data members subject code, internal assessment and university examination marks. Construct a virtual base class for the item name of the student and roll number. The program should have the facilities. i) Build a master table ii) List a table iii) Insert a new entry iv) Delete old entry v) Edit an entry vi) Search for a record


//Program Code

#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<iomanip>

using namespace std;
static int cnt;
class stud
{
 public:
 char name[20];
 int roll;
};
class s2 : public virtual stud
{
 public : char sub[10];
    int scode;
    int sem;
    char div[2];
};
class s1:virtual public stud
{
public : char addr[30];
    int pin;
};
class sdata:public s1,public s2
{
 public : int subc1;
          int im1;
          int um1;
};

int main()
{
  sdata m[100];
  char c='y',str2[10];
  int op,n,i,j,flag=0,rl,r;
  do
  { 
    cout<<"\n * * * * * * Menu  * * * * * *";
    cout<<"\n 1. Build Table \n 2. List a Table \n 3. insert new entry";
    cout<<"\n 4. Delete an entry \n 5. Edit an entry \n 6. Search for record \n Enter your choice :";
    cin>>op;
    switch(op)
     {
       case 1 : cout<<"\n building new Table";
        cout<<"\n Enter total number of Entries :";
                cin>>n;
                for(i=0;i<n;i++)
                {
         cout<<"\n Enter Name of Student :";
                cin>>m[i].name;
        cout<<"\n Enter Roll number     :";
                cin>>m[i].roll;
        cout<<"\n Enter Name of Subject :";
                cin>>m[i].sub;
        cout<<"\n Enter Subject code for Subject "<<m[i].sub<<":";
                cin>>m[i].scode;
        cout<<"\n Enter internal marks for Subject "<<m[i].sub<<":";
                cin>>m[i].im1;
        cout<<"\n Enter University exam marks for Subject "<<m[i].sub<<" :";
                cin>>m[i].um1;
        cnt++;
                 }//for
                break;
       case 2 : cout<<"\n Entries in Table are :";
        cout<<setw(20)<<"\n Name_of_Student"<<setw(8)<<"Roll No"<<setw(12)<<"Subject"<<setw(10)<<"Sub_code"<<setw(12)<<"Internal"<<setw(12)<<"External";   
        cout<<"\n----------------------------------------------------------------------------------------";
        for(i=0;i<cnt;i++)
        {
       
cout<<endl<<setw(10)<<m[i].name<<setw(10)<<m[i].roll<<setw(12)<<m[i].sub<<setw(10)<<m[i].scode<<setw(12)<<m[i].im1<<setw(12)<<m[i].um1;       
        }
        break;
    case 3:j=cnt;
        cout<<"\n Enter Name of Student :";
                cin>>m[j].name;
        cout<<"\n Enter Roll number     :";
                cin>>m[j].roll;
        cout<<"\n Enter Name of Subject :";
                cin>>m[j].sub;
        cout<<"\n Enter Subject code for Subject "<<m[j].sub<<":";
                cin>>m[j].scode;
        cout<<"\n Enter internal marks for Subject "<<m[j].sub<<":";
                cin>>m[j].im1;
        cout<<"\n Enter University exam marks for Subject "<<m[j].sub<<" :";
                cin>>m[j].um1;
        cnt++;
                 break;
     case 4: cout<<"\n Enter record number to delete :";
            cin>>r;
        if(r>0 && r<=cnt)
        {
        j=r-1;
        for(i=j;i<cnt-1;i++)
        {
        m[i]=m[i+1];
          }//for
        cnt--;
        cout<<"\n Record Deleted Successfully ";       
        }//if
        else
            cout<<"\n Entered wrong record number,please enter correct record number \n";   
        break;

    case 5: cout<<"\n Enter record number to edit :";
            cin>>r;
        if(r>0 && r<=cnt) {
        j=r-1;
        cout<<"\n Select Field to Edit : 1. Name \n 2. Roll Number \n 3. Subject Name \n4.Subject code \n5. Internal Marks  \n6. Universirt Exam marks  \n Choice : ";
        cin>>op;
        switch(op)
        {
        case 1 : cout<<"\n Enter New Name of student :";
        cin>>m[j].name;
        break;   

        case 2 : cout<<"\n Enter updated Roll Number of student :";
        cin>>m[j].roll;
        break;
        case 3 :cout<<"\n Enter New Name of Subject :";
                cin>>m[j].sub;
        break;
       
        case 4 : cout<<"\n Enter updated Subject code for Subject "<<m[j].sub<<":";
                cin>>m[j].scode;
        break;
        case 5 : cout<<"\n Enter updated internal marks for Subject "<<m[j].sub<<":";
                cin>>m[j].im1;
        break;
       
        case 6 : cout<<"\n Enter Updated University exam marks for Subject "<<m[j].sub<<" :";
                cin>>m[j].um1;   
        break;       
           }//switch
        }//if
        else
        cout<<"\n Entered wrong record number,please enter correct record number \n";
        break;
    case 6: cout<<"\n Select data type to search :\n 1. Name \n 2.Roll Number \n Choice :";
        cin>>op;
        switch(op)
        {
        case 1:cout<<"\n Enter Name to search in table :";
            cin>>str2;
            flag=0;
            for(i=0;i<cnt;i++)
            {
            if(strcmp(m[i].name,str2)==0)
            {
              flag=1;
              cout<<"\nRecord found for name "<<str2<<". Details are : ";
              cout<<"\n Name    :"<<str2<<"\t Roll :"<<m[i].roll;
              cout<<"\n Subject :"<<m[i].sub<<"\t Subject Code :"<<m[i].scode;   
               cout<<"\n Internal:"<<m[i].im1<<"\t External :"<<m[i].um1;
              }
            else
                continue;
            }//for ends
            if(flag==0)
                cout<<"\n No record found";       
            break;
        case 2 : cout<<"\n Enter roll number to search in table :";
            cin>>rl;
            flag=0;
            for(i=0;i<cnt;i++)
            {
            if(m[i].roll==rl)
            {
              flag=1;
              cout<<"\nRecord found for Roll number "<<rl<<". Details are : ";
              cout<<"\n Name    :"<<m[i].name<<"\t Roll :"<<rl;
              cout<<"\n Subject :"<<m[i].sub<<"\t Subject Code :"<<m[i].scode;   
               cout<<"\n Internal:"<<m[i].im1<<"\t External :"<<m[i].um1;
              }
            else
                continue;
            }//for ends
            if(flag==0)
                cout<<"\n No record found";
        } //switch
        break;
      } //switch completed
   cout<<"\n Do you want to continue (y/n) ? : ";
   cin>>c;
  } while(c=='y'||c=='Y');
cout<<"********** !!! HAVE A GREAT DAY !!!************ \n";
} // program exit

6. Write a program in C++ using function template to read two matrices of different data types such as integers and floating point values and perform simple arithmetic operations on these matrices separately and display it


//Program using Template Function

#include<iostream>
#include<iomanip>
//void add(M, M);
int const size=3;
using namespace std;

//addition function
template <class M, class S>
void add(M a[][size],S b[][size])
{
 S c[size][size];
 for(int i=0;i<size;i++)
    for(int j=0;j<size;j++)
    {
    c[i][j]=a[i][j]+b[i][j];
    }

 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<"   "<<c[i][j];
      }
    cout<<endl;
    }
}

//substraction
template <class M,class S>
void sub(M a[][size],S b[][size])
{
 S c[size][size];
 for(int i=0;i<size;i++)
    for(int j=0;j<size;j++)
    {
    c[i][j]=a[i][j]-b[i][j];
    }

 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<"   "<<c[i][j];
      }
    cout<<endl;
    }
}

//multiplication
template <class M,class S>
void mul(M a[][size],S b[][size])
{
 S c[size][size];
 for(int i=0;i<size;i++)
    {
    for(int j=0;j<size;j++)
    {
      for(int k=0;k<size;k++)
        c[i][j]=a[i][k]*b[k][j];
     }
    }
 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<"   "<<c[i][j];
      }
    cout<<endl;
    }
}

//transpose
template <class M>
void trans(M a[][size])
{
 M c[size][size];
 for(int i=0;i<size;i++)
 {
    for(int j=0;j<size;j++)
    {
    c[i][j]=a[j][i];
    }
  }
cout<<endl<<endl<<"Transpose of matrix :"<<endl;
 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<c[i][j]<<"\t";
      }
    cout<<endl;
    }
}

int main()
{
 int x[size][size],y[size][size];
 float g[size][size],h[size][size];
 int ch;

//Read matrices
 cout<<endl<<"Enter values for Int matrix X:";
 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cin>>x[i][j];
      }
    cout<<endl;
    }

 cout<<endl<<"Enter values for float matrix g:";
  for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cin>>g[i][j];
      }
    cout<<endl;
    }

//Display matrices as entered by user
cout<<endl<<endl<<"Int matrix X:"<<endl;
 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<x[i][j]<<"\t";
      }
    cout<<endl;
    }
cout<<endl<<endl<<"Float matrix G:"<<endl;
 for(int i=0;i<size;i++)
      {
    for(int j=0;j<size;j++)
    {
     cout<<g[i][j]<<"\t";
      }
    cout<<endl;
    }


 do
  {
 cout<<endl<<"************* Operations ****************  \n1.addition of matrix \n2.Substraction of Matrix \n3.Multiplication \n4.Transpose "<<endl<<endl<<"\t Enter Choice";;
 cin>>ch;
 switch(ch)
 {
 case 1 : cout<<endl<<"Result of Addition of matrix X and G : "<<endl;
    add(x,g);
    break;
case 2 : cout<<endl<<"Result of Substraction of matrix X and G : "<<endl;
     sub(x,g);
    break;
 case 3 : cout<<endl<<"Result of Multiplication of matrix X and G : "<<endl;
    mul(x,g);
    break;
case 4 : trans(x);
    trans(g);
    break;
default : cout<<endl<<"Enter valid option"<<endl<<endl;
    break;
 }
}while(ch<6);
return 0;
}



*********************************     *****************************************

//Program using class Template


#include<iostream.h>
#include<conio.h>
template <class t> class mat     //defining class mat
{
    int i,j;
    t m[10][10];
    public:
    void getdata(int,int);
    void putdata(int,int);
    void sub(mat&,mat&,int,int);
    void add(mat&,mat&,int,int);
    void mul(mat&,mat&,int,int,int);
    void trans(mat&,int,int);
};

//defining getdata function
template <class t> void mat <t> :: getdata(int r,int c)
{
    //accepting data from user
    int i=0,j=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            cout<<"Enter value a["<<i<<'] ["<<j<<"]";
            cin>>m[i][j];
        }
    }
}
//defining add function
template <class t> void mat <t> :: add(mat<t> &a1,mat<t>&a2,int r,int c)
{
    int i=0,j=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            //adding two values
            M[i][j]=a1.m[i][j]+a2.m[i][j];
        }
    }
}
//defining subtract function
template <class t> void mat <t> :: sub(mat<t> &a1,mat<t>&a2,int r,int c)
{
    int i=0,j=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            //adding two values
            M[i][j]=a1.m[i][j]-a2.m[i][j];
        }
    }
}
//defining multiplication function
template <class t> void mat <t> :: mult(mat<t> &a1,mat<t>&a2,int r,int c)
{
    int i=0,j=0,k=0;//declaring local variables
    //initializing matrix all values to zero
    for(i=0;i<r;i++)
    for(j=0;j<c;j++)
    m[i][j]=0
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            for(k=0;k<r;k++)
            M[i][j]=m[i][j]+(a1.m[i][k]*a2.m[k][j]);
        }
    }
}
//defining transpose function
template <class t> void mat <t> :: trans(mat<t> &a1,mat<t>&a2,int r,int c)
{
    int i=0,j=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            //adding two values
            M[i][j]=a1.m[j][i];
        }   
    }
}
//defining putdata function
template <class t> void mat <t> :: putdata(mat<t> &a1,mat<t>&a2,int r,int c)
{
    int i=0,j=0;
    for(i=0;i<r;i++)
    {
        cout<<"\n";
        for(j=0;j<c;j++)
        {
            cout<<"\t";
            cout<<m[i][j];
        }
    }
}
int main()
{
    int ch,m,n,x,y   //declaring local variables
    mat<double> p,q,s;
    cout<<"Enter rows & columns of 1st matrix";
    cin>>m>>n;  //accepting rows and columns for 1st matrix;
    cout<<"\n Enter 1st  matrix\n";
    p.getdata(m,n); //calling getdata function
    cout<<"Enter rows and columns of 2nd matrix";
    cin>>x>>y  //accepting rows and columns of second matrix;
    cout<<"\n Enter 2nd matrix\n";
    q.getdata(x,y);  //calling getdata function
    do
    {
        //displaying menu
        cout<<"\nMenu"
        <<"\n1.addition"
        <<"\n2.substraction"
        <<"\n3.Multiplication"
        <<"\n4.Transpose"
        <<"\n Exit"
        <<"\n Enter Your Choice: ;
        cin>>ch;  //accepting choice from user
        switch(ch)
        {
            case 1:
                if(m==x && n==y)  //if rows and cols are same
            {
                cout<<"addition is";
                s.add(p,q,m,n);
                s.putdata(m,n);
            }
            else
            {
                cout<<"addition is not possible";
            }
        break;
            case 2:
                if(m==x && n==y)  )  //if rows and cols are same
            {
                cout<<"sunstraction is";
                s.sub(p,q,m,n);
                s.putdata(m,n);
            }
            else
            {
                cout<<"substrction is not possible";
            }
        break;
            case 3:
                if (n==x)  //if cols of first matrix is equal to rows of second matrix
            {
                cout<<"Multiplication is";
                s.mult(p,q,m,n);
                s.putdata(m,n);
            }
            else
            {
                cout<<"multiplication is not possible";
            }
        break;
            case 4:
                cout<<"Transpose is:\n";
                s.trans(p,m,n);
                s.putdata(m,n);
        break;
            case 5:
                cout<<"\n Exiting..\n";
        }\\end of switch
    }while(ch!=5);//end of while
    return 0;
}end of main

5. Write a C++ program to perform String operations : i. = Equality ii. == String Copy iii. + Concatenation iv. << To display a string v. >> To reverse a string vi. Function to determine whether a string is a palindrome To find occurrence of a sub-string. Use Operator Overloading



/* Problem Statement:

Write a C++ program to perform String operations :
i.     = Equality                 ii.     == String Copy
iii.     + Concatenation            iv.     << To display a string
v.     >> To reverse a string        vi.     Function to determine whether a string is a palindrome
vii. To find occurrence of a sub-string.
             Use Operator Overloading   */


// Code

#include<iostream>
#include<string>
#include<stdlib.h>

using namespace std;

class stg
{
  char str[20];
  int len;
  public:
  stg() { len=0; }

  void read()
  {
    cout<<"\nEnter the string : ";
    cin>>str;
  }

  int operator ~()
  {
    int i;
    len=0;
    for(i=0;str[i]!='\0';i++)
    {
     len++;
    }
    return(len);
  }

  friend istream &operator >>(istream &in,stg &s)
  {
    int i;
    ~s;
    cout<<"\nReverse string: ";
    for(i=s.len-1;i>=0;i--)
    {
      cout<<s.str[i];
    }
  }

  void operator ==(stg s)
  {
     read();
     int i;
     char str2[20];
     for(i=0;str[i]!='\0';i++)
       str2[i]=str[i];
     str2[i]='\0';
    cout<<"\nCopied String : ";
    cout<<str2;
  }

  void operator +(stg s2)
  {
    ~*this;
    int j=len;
    for(int i=0;s2.str[i]!='\0';i++)
    {
       str[j]=s2.str[i];
       j++;
    }
    str[j]='\0';
    cout<<str;
  }

  void operator =(stg s2)
  {
    int i,f=0;
    for(i=0;str[i]!='\0';i++)
    {
       if(str[i]==s2.str[i])
       {
     f=1;
       }
      else
     f=0;
     break;
    }
    if(f==1)
     cout<<"\nStings are equal!";
    else
     cout<<"\nStrings are not equal";
  }
  void operator ||(stg s2)
  {
    int i,j=0,f=0,count=0;
    cout<<"\nPositions of occurence: ";
    for(i=0;str[i]!='\0';i++)
    {
       if(str[i]==s2.str[j])
       {
    j++;
       }
       else
       {
    j=0;
       }
       if(s2.str[j]=='\0')
       {
     f=1;
     count++;
     cout<<"  "<<(i-j+2);
     j=0;
       }
    }
    cout<<"\nNo of occurence of substring: "<<count;
  }

  void operator !()
  {
    int f=0;
    ~*this;
    for(int i=0;i<len;i++)
    {
      if(str[i]==str[len-i-1])
     f=1;
      else
       {
     f=0; break;
       }
    }
    if(f==1)
      cout<<"\nIt is a pallindrome!";
    else
    cout<<"\nIt is a NOT pallindrome!";
  }


friend ostream &operator <<(ostream &out,stg &s)
  {
     out<<s.str;
     return(out);
  }
};

int main()
{
int c,l;
 char m;
 stg s1,s2;
 do
 {
 cout<<"\n\n\n\tMENU:\n1.Length of the string\n2.Copy\n3.Reverse\n4.Concatination\n5.Compare two strings\n6.Find Substring\n7.Pallindrome \n8. Exit \nChoice= ";
 cin>>c;
 switch(c)
 {
  case 1: s1.read();
      l=~s1;
      cout<<"\nLength of the string is: "<<l;
      break;
  case 2: s1==s2;
      break;
  case 3: s1.read();
      cin>>s1;
      break;
  case 4: cout<<"First String :"; s1.read();
      cout<<"Second String :"; s2.read();
      s1+s2;
      break;
  case 5: cout<<"First String :"; s1.read();
      cout<<"Second String :"; s2.read();
      s1=s2;
      break;
  case 6: cout<<"Original String :"; s1.read();
      cout<<"Substring to search :"; s2.read();
      s1||s2;
      break;
  case 7: s1.read();
      !s1;
      break;
  case 8: exit(1);
      break;
  default:cout<<"Invalid";
      break;
  }
  //cout<<"\nDo you want to continue?-y/n: ";
  //cin>>m;
  }while(c!=8);
 return 0;
}

4. Design a C++ Class ‘Complex’ with data members for real and imaginary part. Provide default and parameterized constructors. Write a program to perform arithmetic operations of two complex numbers using operator overloading (using either member functions or friend functions).


Design a C++ Class ‘Complex’ with data members for real and imaginary part. Provide default and parameterized constructors. Write a program to perform arithmetic operations of two complex numbers using operator overloading (using either member functions or friend functions).

*/


/* Complex.cpp*/

#include<iostream>
Using namespace std;

class complex
{
  float real,imag;
  public:
  complex()
  {
    real=imag=0;
  }

  void getdata()
  {
    cout<<"\nEnter the real and imaginary part of complex no : ";
    cin>>real>>imag;
  }

  void display()
  {
       if(imag>=0)
         cout<<"\n"<<real<<"+"<<imag<<"i";
      else
      cout<<"\n"<<real<<"-"<<abs(imag)<<"i";
 
  }

  complex operator +(complex c1)
  {
    complex c3;
    c3.real=real+c1.real;
    c3.imag=imag+c1.imag;
    return c3;
  }

  complex operator -(complex c1)
  {
    complex c3;
    c3.real=real-c1.real;
    c3.imag=imag-c1.imag;
    return c3;
  }

  complex operator *(complex c1)
  {
    complex c3;
    c3.real=real*c1.real-imag*c1.imag;
    c3.imag=real*c1.imag+imag*c1.real;
    return c3;
  }

  complex operator /(complex c1)
  {
    complex c3;
    float den;
    den=c1.real*c1.real-c1.imag*c1.imag;
    c1.imag=c1.imag*(-1);
    c3.real=real*c1.real-imag*c1.imag;
    c3.imag=real*c1.imag+imag*c1.real;
    c3.real=c3.real/den;
    c3.imag=c3.imag/den;
    return c3;
  }
};

void main()
{
  int m;
  char n;
  complex c1,c2,c3,c4,c5,c6;
  c1.getdata();
  c2.getdata();
  cout<<"\nGiven two complex numbers:\n";
  c1.display();
  c2.display();
  do
  {
  cout<<"\nMENU:\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\nChoice= ";
  cin>>m;
  switch(m)
  {
  case 1: cout<<"\n\nAddition:\n ";
      c3=c1+c2;
      c3.display();
      break;
  case 2: cout<<"\n\nSubtraction:\n ";
      c4=c1-c2;
      c4.display();
      break;
  case 3: cout<<"\n\nMultiplication:\n ";
      c5=c1*c2;
      c5.display();
      break;
  case 4: cout<<"\n\nDivision:\n ";
      c6=c1/c2;
      c6.display();
      break;
  }
  cout<<"\nDo you want to continue-y/n : ";
  cin>>n;
  }while(n=='y');
}

3. Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name, Date of Birth, Blood group, Height, Weight, Insurance Policy, number, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz. constructor, default constructor, copy, constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.


/* Problem Statement:

Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name, Date of Birth, Blood group, Height, Weight, Insurance Policy, number, Contact address, telephone number, driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz. constructor, default constructor, copy, constructor, destructor, static member functions, friend class, this pointer, inline code and dynamic memory allocation operators-new and delete.

*/

#include<iostream>
#include<string>
#include<cstring>
using namespace std;
class person
{
    private:
    char name[40],dob[15],bdg[15];
    int h,w;
    public:
    static int count;
    friend class personal;
    person()
    {
        char * name=new char[40];
        char *dob=new char[80];
        char *bdg=new char[15];
        h=w=0;
    }
    static void recordcount()
    {
        cout<<"\n Total no of records :"<<count;
    }
};

class personal
{
private:
  char add[70],telephone[15],policy_no[10];
public:
 personal()
{
    strcpy(add,"");
    strcpy(telephone,"");
    strcpy(policy_no,"");
}
void getdata(person *obj);
void displaydata(person *obj);
friend class person;
};
int person::count=0;
void personal::getdata(person *obj)
{
cout<<"\n Enter Name of Person=";
cin>>obj->name;
cout<<"\n Enter date of birth of person=";
cin>>obj->dob;
cout<<"\n Enter blood group of person=";
cin>>obj->bdg;
cout<<"\n Enter height and weigth of person=";
cin>>obj->h>>obj->w;
cout<<"\n Enter Contact no of person=";
cin>>this->telephone;
cout<<"\n Enter addreass of person=";
cin>>this->add;
cout<<"\n Enter the insurance policy no=";
cin>>this->policy_no;
obj->count++;
}
void personal::displaydata(person *obj)
{

cout<<obj->name<<"\t"<<obj->dob<<"\t\t"<<obj->bdg<<"\t"<<obj->h<<"\t\t"<<obj->w<<"\t"<<this->telephone<<"\t"<<this->policy_no<<"\t"<<this->add;
}
int main()
{
personal *p1[30];
person *p2[30];
int n=0,ch,i;
do
{
cout<<"\n Menu";
cout<<"\n 1.Information of Person \n 2.Display Information \n 3.Exit";
cout<<"\n Enter your choice";
cin>>ch;
switch(ch)
{
case 1:
 cout<<"\n Enter The Information";
 cout<<"\n";
 p1[n]=new personal;
 p2[n]=new person;
p1[n]->getdata(p2[n]);
n++;
person::recordcount();
break;
case 2:
 cout<<"\n";
cout<<"\n*******************************************************************\n";
cout<<"NAME"<<"\t"<<"DATE OF BIRTH"<<"\t"<<"BLOOD GROUP"<<"\t"<<"HEIGHT"<<"\t"<<"WEIGHT"<<"\t"<<"TELEPHONE NO"<<"\t"<<"INSU.POLICYNO"<<"\t"<<"ADDRESS \n";
cout<<"\n";
for(i=0;i<n;i++)
{
p1[i]->displaydata(p2[i]);

}
person::recordcount();
break;
}
}while(ch!=4);
return 0;
}

2. A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies book details and requests for the number of copies required. If the requested copies are available, the total cost of the requested copies is displayed; otherwise the message “Required copies not in stock” is displayed. Design a system using a class called books with suitable member functions and Constructors. Use new operator in constructors to allocate memory space required. Implement C++ program for the system

/* Problem Statement:

A book shop maintains the inventory of books that are being sold at the shop. The list includes details such as author, title, price, publisher and stock position. Whenever a customer wants a book, the sales person inputs the title and author and the system searches the list and displays whether it is available or not. If it is not, an appropriate message is displayed. If it is, then the system displays the book details and requests for the number of copies required. If the requested copies book details and requests for the number of copies required. If the requested copies are available, the total cost of the requested copies is displayed; otherwise the message “Required copies not in stock” is displayed.
Design a system using a class called books with suitable member functions and Constructors. Use new operator in constructors to allocate memory space required. Implement C++ program for the system

*/


/* Bookshop.cppp*/
#include<iostream>
#include<string.h>
#include<stdlib.h>

using namespace std;
class book
{

 char author[20]; 
 char title[20];
 char publisher[20];
 double price;
 int stock;
   public:
     book();    
   void insertdata();
   void display();
   int search(char[],char[]);
   void nocopies(int);     
};
  book::book()
  {
    char *author=new char[50];
    char * title=new char[50];
    char *publisher=new char[50];
    price=0;
    stock=0;
   }
void book::insertdata()
         {
  cout<<"\n Enter the name of Book:";
  cin>>title;
  cout<<"\n Enter The Name Of Author:";
  cin>>author;
  cout<<"\n Enter The name of Publisher:";
  cin>>publisher;
  cout<<"\n Enter the Price of book:";
  cin>>price;
  cout<<"\n Enter Stock of book:";
  cin>>stock;
 }


  void book::display()
 {
 cout<<"\n "<<title<<"\t\t "<<author<<"\t\t  "<<publisher<<" \t\t\t "<<price<<"\t "<<stock;
        }
  int book::search(char t[],char a[])
  {
      if(strcmp(title,t)&&(strcmp(author,a)))
 {
 return 0;
 }
 else
 {
 return 1;
 }
  }

 void book::nocopies(int num)
{
if(stock>=num)
{
cout<<"\n Title is avilable";
cout<<"\n Cost of"<<num<<"Books is Rs."<<(price*num);
}
else
{
cout<<"\n Required copies not in stock";
}
}
int main()
{
 int ch,n,i,flag=0,copies,key=0;
          book b[100];
          char bname[50];
          char key_title[50],key_author[50];
   do
    {
 cout<<"\n************Book Store*******************";
 cout<<"\n 1.Insert Details of book \n 2.Display \n 3.search \n 4.exit";
 cout<<"\n Enter Your Choice:";
 cin>>ch;
 switch(ch)
  {
      case 1:
                    cout<<"\n How many books data u want to enter";
                    cin>>n;
                    for(i=0;i<n;i++)
                      {
                       b[i].insertdata();
   }
                     break;
     case 2:
                       cout<<"\n"<<"TITLE"<<"\t \t "<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t "<<"STOCK";
                        for(i=0;i<n;i++)
    {
                        cout<<"\n";
   
         b[i].display();   
     }
   
                        break;
                    
   case 3:
                          cout<<"\n Enter title of required book";
                           cin>>key_title;
                           cout<<"\n Enter author of required book";
                            cin>>key_author;
                             
                            for(i=0;i<n;i++)
                          {
                              if(b[i].search(key_title,key_author))
                               {
                                  flag=1;
 cout<<"\n"<<"TITLE"<<"\t \t "<<"AUTHOR"<<"\t\t"<<"PUBLISHER"<<"\t\t"<<"PRICE"<<"\t "<<"STOCK";
                                  b[i].display();                        
    //break;
    key=i;
            }
    }
   if(flag==1)                          
    cout<<"\n Book is available";
   else
 {
     cout<<"\n book is Not available";
        break;
 }        
              if(flag==1)
                      {
                      cout<<"\n Please enter the required number of copies of the book";
                       cin>>copies;
                      b[key].nocopies(copies);
                     }
                   
                     break;
                case 4: exit(EXIT_SUCCESS);
   break;
  default :
                    cout<<"\n Wrong Choice";
                       break;
 }   
   }while(ch!=5);
 return 0;
} 

Friday 26 September 2014

Python Program to check if system is Booted with BOIS or UEFI


*********** Execute This code on Windows system **********



#bios.py

def check():
    infile=open("c:\windows\panther\setupact.log","r+");
    available=False
    for line in infile:
        if"Detected boot environment:BIOS" in line:
in line
        available=True
        break
    return available

available=check()
if available:
    print(".......System Boot type : Legacy Boot ROM-BIOS......!!!")
else:
    print(".......System is Booted with UEFI.....")





Java Program to verify Mobile Device OS Version and name

Execute This program on Eclipse for Android

Create .apk file using emulator and execute .apk  file on Android OS



import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity
{
  @override
public void onCreate(Bundle savedInstanceState)
{
 super.onCreate(savedInstanceState);
TextView text=new TextView(this);

text.setText("\n System Information "+"\n Operating System Name :"+System.getProperty("os.name")+"\n Version "+
System.getProperty("os.version")+"\n Architecture :"+System.getProperty("os.arch")+"\n Manufacturer :"+
android.os.Build.MANUFACTURER+"\n Display type :"+android.os.Build.DISPLAY+"\n Model :"+
android.os.Build.MODEL+"\n Product:"+android.os.Build.PRODUCT+"\n User:"+android.os.Build.USER);
}
}

Friday 19 September 2014

Write a program in C++ to make USB Device Bootable by installing required system files

To Create Bootable USB , we need to copy following files in USB.
Write a program in C++ top copy a file from Your system to USB drive.

Files Required to create a Bootable Drive :
1. CONFIG.SYS
2. SYS.COM
3. IO.SYS
4. MSDOS.SYS
5. COMMAND.SYS


On copying these files just restart your system.

We can copy more files from MSDOS system files to add more functionality.
Following is list of various MSDOS System Files that can be used to add more
functionality.

List of MS-DOS system files
MS-DOS / PC DOS and some related disk operating systems use the files mentioned here.

System Files:
• IO.SYS (or IBMBIO.COM): This contains the system initialization code and
builtin device drivers.
• MSDOS.SYS (or IBMDOS.COM): This contains the DOS kernel.

Command line interpreter (Shell):
• COMMAND.COM: This is the command interpreter.

User configuration files:
• AUTOEXEC.BAT: This is run by the default shell (usually COMMAND.COM) to
execute commands at startup.
• CONFIG.SYS: This contains statements to configure DOS and load device
drivers.

Standard DOS utility programs:
• APPEND: Set a search path for data files.
• ATTRIB: Set or display file attributes.
• BACKUP / RESTORE: simple backup and restore utilities.
• CHKDSK: Check disk for file system integrity.
• COMP / FC: File compare utilities.
• DEBUG: Simple command line debugger.
• DELTREE: Delete a directory tree.
• DISKCOMP: Compare floppy disks.
• DISKCOPY: Copy floppy disks.
• DOSKEY: Command line editor.
• EDIT / EDLIN: Very basic text editor(s); EDLIN is in earlier versions.
• FDISK: Partitions fixed disks.
• FIND: Find text in files.
• FORMAT: Formats disks.
• JOIN: Joins a drive letter to a subdirectory.
• LABEL: Set or remove a disk volume label.
• MEM: Display memory usage.
• MODE: Set modes for system devices.
• MORE: Display output one screen at a time.
• MOVE: Move files from one directory to another.
• PRINT: Print spooler.
• REPLACE: Replace files.
• SHARE: File sharing and locking support.
• SORT: Sorts input.
• SUBST: Substitutes a drive letter for a subdirectory.
• SYS: Transfers the system files to another drive to make it bootable.
• TREE: Display a directory tree.
• XCOPY: Extended file copy.
Standard DOS device drivers:
• ANSI.SYS: ANSI console driver.
• EMM386.EXE: Expanded memory manager.
• HIMEM.SYS: Extended memory manager.
• RAMDRIVE.SYS / VDISK.SYS: RAM disk; VDISK.SYS is in older versions of PC
DOS.

Download required files to a directory (eg: Documents)

Sample C++ code :

Add lines of code for remaining files.

#include<stdlib.h>
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
 ofstream fpon;
 ifstream fpin;
 string line;

fpin.open("/home/Downloads/CONFIG.SYS");
fpon.open("/dev/sdb1/CONFIG.SYS");

 if(fpin.is_open())
  {
   while(getline(fpin,line))
    {
          fpon<<line;
         } //while ends
    } //if ends

 fpon.close();
 fpin.close();

    //in same way write code for reamining files , repeat above code and change
    //name of file only.

cout<<"All files copied"<<endl<<"Now device is bootable";
return 0;

}//main ends

How to Format USB Drive in the Terminal

I see formatting USB drives from the terminal very handy. Today I am going to show you how to format USB drives using the terminal. Things needed for this tutorial to be useful is just a USB drive, the capacity doesn’t matter.
Let us get started!
1. Insert your USB drive into your system.
2. Open the terminal. (CTRL + ALT + T)
3. Look for the USB drive you want to format, by running:
$ df
The command above will display the directory path of your various drives. Take note of the drive you wish to format.
df-command-unixmenIn this tutorial, the name of the drive am going to format is Seth and its path under the filesystem is /dev/sdc1.
3. Unmount drive using the syntax below:
$ sudo umount /dev/sdc1
umount4. Now run this command to format drive to fat32:
$ sudo mkfs.vfat -n 'Ubuntu' -I /dev/sdc1
mkfs.vfat-unixmen
Understanding the above command
mkfs
mkfs is used to build a Linux filesystem on a device, usually a hard disk partition. The device argument is either the device name (e.g. /dev/hda1, /dev/sdb2), or a regular file that shall contain the filesystem. The size argument is the number of blocks to be used for the filesystem.
vfat
Formats the drive to FAT32, other formats available are mkfs.bfs, mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.minix, mkfs.msdos, mkfs.vfat, mkfs.xfs, mkfs.xiafs etc.
-n
Volume-name sets the volume name (label) of the file system. The volume name can be up to 11 characters long. The default is no label. In this tutorial my volume-name is Ubuntu.
-I
It is typical for fixed disk devices to be partitioned so by default, you are not permitted to create a filesystem across the entire device.
format-completeRunning $ df after formatting displays this.
df-after-format-unixmenYou are done and your pen drive has successfully been formatted.

Tuesday 16 September 2014

C++ Program to create RAMDRIVE or RAMDISk and run Calculator Program in it.

1. Create Input File in /tmp/ramdisk for input
          name it as input.txt

2. Write a Program for calculator in C

code is as follow

#include<stdio.h>
#include<stdlib.h>
int main()
{
 int a,b,res;
 FILE *fp;
 fp=fopen("/tmp/ramdisk/input.txt","r");
 fscanf(fp,"%d",&a);
 fscanf(fp,"%d",&b);
 fclose(fp);
  fp=fopen("/tmp/ramdisk/output.txt","w");
 fprintf(fp,"\n Addition is :%d ",(a+b));
return 0;
}


save it as calci.c and compile using command
          gcc calci.c -o  calculator


3. Write program for RAMDISK in C language
     
    #include<stdio.h>
#include<stdlib.h>
int main()
{
  printf("\n RAMDISK creation for 512M size");
  system("rmdir /tmp/ramdisk");
  system("mkdir /tmp/ramdisk");
  system("chmod 777 /tmp/ramdisk");
  system("mount -t tmpfs -o size=512M tmpfs /tmp/ramdisk/");
  printf("\n RAMDISK created");
  system("df -h|grep ram");
  system("cp input.txt /tmp/ramdisk");
  system("cp calculator /tmp/ramdisk");
  return 0;
}

save it as ramdisk.c and compile as

gcc ramdisk.c -o ramdisk

execute output of above command as
        ramdisk <Enter>

4. Calculator code can be executed using command
        /tmp/ramdisk/calculator

5. Output is saved in output.txt file. Check it from /tmp/ramdisk/output.txt





Friday 5 September 2014

Python program for socket programming to connect two or more PC to share a text file

#1.Server side code

#!/usr/bin/python

import socket
import os

s=socket.socket()      #socket type object created
host=192.168.1.214    #server address
port=21110        #port reserverd for connection
s.bind((host,port))

s.listen(10)

while True:
    c, addrs= s.accept();
    print'Connection created with machine',addrs
    name=c.recv(100)    #receive file name to be read/shared
    print name,'File requested by User'
    file=open(name,"r")    #open file in read mode
   
while True:
    cha=file.read(65500)    #read data from file upto 65500 bytes
    if not cha:
    break            #reached end of file
   c.sendall(cha)        #send file content to requester
c.close()            #close connection


*********************** ******************************

#2.Client side code

#!usr/bin/python

import socket

s=socket.socket()        #socket object created
host=192.168.1.214
port=21110

s.connect((host,port))        #connect with sserver on port
print'Enter file name to be read'
name=raw_input()        #accept input from user
s.send(name)            #send name of file to server
print s.recv(65500)        #receive data from server and print on screen
s.close()            #close connection with server





#change host number as per your system configuration for ip address
#host should be server machine address

Sunday 31 August 2014

PERL PROGRAM TO COUNT nunber of Words, lines and charachters in a file

// Demo.pl


$line=0;
$word=0;
$char=0;

print("\n Count Line,word,character");
open(FILE,"Demo1.sh");
while(<FILE>)
{
$line++;
$char+=length($_);
$word+=scalar(split(/\W+/,$_));
}

print("\nline   word   char  ");
print("\n$line   $word  $char \n");

close(FILE);

******************Sample OUTPUT**********************
//My program is saved on desktop
//Demo1.sh is input file...as per need change name of input file which is located in same directory

svcet@svcet-MS-7636:~$ cd Desktop
svcet@svcet-MS-7636:~/Desktop$ perl Demo.pl

 Count Line,word,character
line   word   char 
2   11  61

Steps to Use Magic ISO Maker For Creating ISO Image and working with ISO Image.

  1. How to quickly create an new ISO files or an new CD/DVD.
  2. How to edit ISO files.
  3. How to make ISO from CD-ROM
  4. How to extract boot image from CD/DVD-ROM.
  5. How to make bootable image from floppy disk.
  6. How to make bootable ISO image.
  7. How to convert CD/DVD image format.
  8. How to burn CD/DVD with CD/DVD image file.

  • Quickly create an new ISO file or an new CD/DVD

    1. Click menu "Files" ->"New" to choose which type of ISO image you want to create



    Data CD/DVD image:  The new ISO image contains two file systems  - ISO 9660 and Joliet. This ISO image or CD/DVD burnt with this ISO image can be read on Microsoft Windows.

    Bootable CD/DVD image:  Create a bootable ISO image with choosing bootable image file that can be get from bootable floppy disk or another bootable ISO image. The new ISO image contains two file systems  - ISO 9660 and Joliet.  This ISO image or CD/DVD burnt with this ISO image can be read on Microsoft Windows.

    UDF CD/DVD image:  Create UDF-ONLY ISO image.

    Hybrid CD/DVD image: The new ISO image contains four file systems  - ISO 9660,  Joliet, UDF and Apple HFS+. The ISO image or CD/DVD burnt with this ISO image can be read on Microsoft Windows and Mac OS X.

    Unix/Linux CD/DVD image: The new ISO image contains three files systems - ISO 9660, Joliet and RockRidge. The ISO image or CD/DVD burnt with this ISO image can be read on Microsoft Windows ,Linux and Unix.

    2. Dragging files or directories from Local Browser  into ISO Panel. or click the button " or to add files or directories.



    3. Click to create an new folder. Then enter the folder name.



    4. Click to delete files or folders.

    5. Press F2 or click to rename file name, folder name or volume name.

    >>For creating an new ISO image.
    6. Click to save in ISO image.



    >>For creating an new CD or DVD.

    6. Click to burn CD/DVD on-the-fly.



    7. Choose your CD/DVD recorder, Choose write speed. Important: you must remember to clear the "Finalize CD" checkbox if you need to write data onto this CD or DVD later. With a Multisession CD or DVD, this checkbox is only checked for the last session of the CD or DVD. This setting write protects the CD or DVD and no further writing is possible.

    8. Click "Burn it!" button to start the burn process.

  • Using MagicISO to edit ISO file

    1. Click to open ISO file or choose File menu and Click Open Command.

    2. Dragging files or directories from Local Browser  into ISO Panel. or click the button " or to add files or directories.

    3. Click to create an new folder. Then enter the folder name.

    4. Click to delete files or folders.

    5. Press F2 or click to rename file name, folder name or volume name.

    6. Click to save in ISO image.




    >>For creating an new CD.
    6. Click to burn CD/DVD on-the-fly.



    7. Choose your CD/DVD recorder, Choose write speed. Important: you must remember to clear the "Finalize CD" checkbox if you need to write data onto this CD or DVD later. With a Multisession CD or DVD, this checkbox is only checked for the last session of the CD or DVD. This setting write protects the CD or DVD and no further writing is possible.

    8. Click "Burn it!" button to start the burn process.

     
  • Make ISO from CD/DVD-ROM

    1. Click Menu "Tools"->"Make ISO from CD/DVD-ROM"





    2.  Choose "Source CD/DVD-ROM"



    3. Enter output file name

    4. Choose output format for your CD/DVD.



    Standard ISO image file (.ISO): It is used for All kind of DVD Disc and Data CD with single track.

    BIN image file (.BIN/.CUE): It is used for Audio CD, Video CD, Super Video CD and all CD with single session.

    NRG image file (.NRG): It is used for All kind of CD (include Audio CD, Video CD, Super Video CD and Data CD etc.)

    Universal Image Format ( *.UIF): It is used for all kind of CD and DVD. It is strongly recommended for backuping your CD or DVD. Read here to learn more.

    5. If you choose "Universal Image Format(*.UIF)" as output format, you can enter password for protecting your image file.

    6. Click "Ok" to process.

     
  • Extract boot image from CD/DVD-ROM

    1. Click Menu "Tools"->"Make ISO from CD/DVD-ROM"



    2.  Choose "Source CD/DVD-ROM"



    3. Enter output file name.

    4. Check "Export Boot Image".

    5. Click Ok button to process.

     
  • Make boot image from floppy disk

    1. Click menu "Tools"->" Make boot image from floppy disk"

    2. Enter the name of bootable image file to save.

     
  • Make bootable ISO image

    1.  Open an ISO image.

    2. Click to set boot image file.

    3. Click button to save ISO file.

     
  • Convert CD/DVD image

    1.  Click menu "Tools"->"Convert ..."



    2. Enter source file name,   Choose output format, Enter output file



    3. Click "Convert"

    Click here to learn about how to convert .DMG to ISO image.


     
  • Burn CD/DVD with CD/DVD image file

    1. Click to open "Burn CD!" Dialog



    2. Choose CD/DVD-Writer

    3. Enter CD/DVD image filename

    4. Choose writing speed.

    5. Click "Burn it!"

Write a program in Python/C++ to read display the i-node information for a given text file,image file.

#!/usr/bin/python

import os, sys

# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Now get  the touple
info = os.fstat(fd)

print "File Info :", info

# Now get uid of the file
print "UID of the file :%d" % info.st_uid

# Now get gid of the file
print "GID of the file :%d" % info.st_gid

# Now get inode of the file
print "i-node number of the file :%d" % info.st_ino

# Now get size of the file
print "size of the file :%d" % info.st_size

# Now get number of blocks for the file
print "number of blocks allocated for file :%d" % info.st_blocks

# Close opened file
os.close( fd)