Wednesday, 2 May 2012


Program given in the class on 2 may 2012
class Applicant                                       // class decription
{ long Ano;
char Name[20];
float Agg;
char Grade;
void Grademe();
public:
void Enter();
void Result();     };

void  Applicant :: Grademe()                    // function to set the grade
{ if (Agg>=80)
Grade=’A’;
else if (Agg>=65 && Agg<80)
Grade=’B’;
else if(Agg>=50 && Agg<65)
Grade=’C’;
else
Grade=’D’; }

void Applicant:: Enter()                           // function to input values
{cout<<”enter the Admission no, name and aggregate marks for the student\n”;
cin>>ANo>>Name>>Agg; }

void Applicant :: Result ()                       // function to display values
{  cout<<”ANo, Name, Aggreagate marks and Grade of the Student is as”;
cout<<”\n”<<Ano<<”\n”<<Name<<”\n”<<Agg<<”\n”<<Grade; }

4 comments:

  1. Guyz dont forget to compile it on Turbo C++ by hitting Ctrl + F9 !!

    A few in my vicinity dont know that.. :)

    ReplyDelete
  2. Find the output :-
    void main()
    {
    int k[ ] = {100,200,300,400,500,600,700};
    int *t=k+2;
    cout<<*t;
    cout<<"\n"<<*(t+2) + *t;
    *t = *t + 10;
    cout<<*t;
    t=t+3;
    cout<<*t
    *t = *t + *(t-2);
    cout<<*t;
    }
    A.
    300
    900
    320
    600
    1000
    B.
    300
    800
    310
    600
    1000
    C.
    100
    900
    310
    600
    1000
    D.
    300
    800
    310
    600
    900
    E.
    None of the above

    ReplyDelete
  3. 2. Find the Output.
    #include
    #include
    #include
    struct KEY
    {
    char word[10];
    int count;
    };
    void changekeyword(KEY somekey);

    void main()
    {
    KEY aKEY;
    strcpy(aKEY.word, “#define”);
    aKEY.count=0;
    changekeyword(aKEY);
    cout<<"\n"<<aKEY.word<<"\t"<<aKEY.count;
    getch();
    }
    void changekeyword(KEY somekey)
    {
    strcpy(somekey.word, “const”);
    somekey.count=1;

    }
    A.
    const 0
    define 1
    B.
    define 0
    const 1
    C.
    const 1
    define 0
    D.
    const 10
    define 0
    E.
    const 1
    define 10

    ReplyDelete
  4. 3. Find the Output-
    #include
    #include
    class state
    { char *state_name;
    int size;
    public:
    state( ); { size=0; state_name=new char[size+1]; }
    state(char *s)
    { size = strlen(s) ; state_name = new char[size+1];
    strcpy(state_name,s);
    }
    void display( ) {cout<
    void Replace (state & a, state & b)
    { size = a.size + b.size;
    delete state_name;
    state_name = new char[size+l];
    strcpy(state_name, a.state_name);
    strcat(state_name, b.state_name);
    }
    };
    void main( )
    { char * temp = “Delhi”;
    state state1 (temp), state2(“Mumbai”), state3(“Nagpur”), S1, S2;
    S1.Replace(state1, state2);
    S2. Replace(S1, state3);
    S1.display( );
    S2.display( );
    }


    A.
    DelhiMumbai
    DelhiMumbaiNagpur
    B.
    Delhi Mumbai
    Delhi Mumbai Nagpur
    C.
    DelhiMumbaiNagpur
    DelhiMumbai
    D.
    MumbaiDelhi
    DelhiMumbaiNagpur
    E.
    DelhiMumbai
    NagpurDelhiMumbai

    ReplyDelete