Answer:
1.
class TIME
{
int hour , min , sec ;
public :
TIME()
{
hour=min=sec=0;
}
TIME( int h , int m , int s )
{
hour = h;
min = m;
sec = s;
}
void change ( int Hour)
{
hour = Hour;
}
void stdtime()
{
if(hour>12)
cout<<"The Standard time is"<<(hour-12)<<":"<<min<<":"<<sec<<"P.M\n";
else
cout<<"The Standard time is"<<hour<<":"<<min<<":"<<sec<<"A.M\n";
}
void miltime()
{
cout<<"The Military time is"<<hour<<":"<<min<<":"<<sec<<" hours\n";
}
};
void main()
{
TIME A , B(13,25,30);
A .stdtime();
A.change(23);
A.miltime();
B.stdtime();
B.change(9);
B.miltime();
}
2.
class elevator
{
int CurrentFloor;
int GoingUp;
int GoingDown;
public:
elevator()
{
CurrentFloor=0;
GoingUp=1;
GoingDown=-1;
}
elevator(int floor)
{
CurrentFloor=floor;
GoingUp=1;
GoingDown=-1;
}
void goUp(int y)
{
if( CurrentFloor>3)
cout<<"\nNO MORE FLOORS\n";
else
CurrentFloor=CurrentFloor+y*GoingUp;
}
void goDown(int x)
{
if(CurrentFloor<0)
cout<<"\nNO MORE FLOORS";
else
CurrentFloor=CurrentFloor+x*GoingDown;
}
};
void main()
{
elevator A(1);
A.goUp(1);
A.goUp(1);
A.goUp(1);
A.goDown(1);
A.goDown(1);
}
Answer:
The expression is "t[k]".
Explanation:
In the question, it is defined that variable k refers to positive integer and variable t refers to a tuple that holds at least k+1 element. The expression for defining the kth element of t is t[k].
- Where variable t is tuple that collects a sequence of immutable (in-built) Python objects. To define tuple we use the parentheses.
- The main purpose to use tuple in this question is that it cannot be changed.
Answer:
Binary Code
Explanation:
All microprocessors and programmable devices understand is Binary Code. These are various combinations of 0's and 1's which when placed together in a sequence represent a set of instructions that the microprocessor can read and understand to complete complex tasks. There are various other programming languages to program these tasks in an easier to read syntax for the programmers themselves but they simply take the written code and convert it into Binary before sending it to the microprocessor.