اسئلة واجوبة لسنوات سابقة
  أستــاذ المــادة  هديل قاسم غني
  تـاريـخ النشــر   10/01/2018
Share |


Q1/ Suppose you have a box of Keys you would like to buy, write a C++ program to check if the number is greater than 66 divide the keys on 3, and then compare whether the output is greater than 30 then the price will be 25 otherwise would be 20, but if the number is less than 66 then the price is equal to 10.

Sol.

#include<iostream.h>

#include<conio.h>

Void main()

{ clrscr();

  Int x;

Cin>>x;

If(x>=66)

{ av=x/3;

  If(av>30)

 Cout<<"The Price is 25"<<endl;

Else

  Cout<<" The Price is 20"<<endl;

}

Else

Cout<<" The Price is 10"<<endl;

Getch();

}

Q2/ Write a C++ program to calculate the student s estimation as given bellow using switchstatement.

90 ? A ? 100                          80 ? B < 90                            70 ? C < 80

60  < D < 70                                    F < 60

 

Sol.

Cin>>x;

Y=x/10;

Switch(y)

{

Case 10:

Case 9: cout<< A ; break;

Case 8: cout<< B ; break;

Case 7: cout<< C ; break;

Case 6: cout<< D ; break;

Case 5:

Case 4:

Case 3:

Case 2:

Case 1: cout<< F ; break;

Default: cout<<"Error";

Getch();

}

Q3/ Write a C++ program to read a number of days and then find the number of years, the number of months and the number of days in that number.

Sol.

Int day,year,month;

Cin>>day;

Year=day/365;

Month=day/30;

Cout<<" We have "<<year<<"year and"<<month<<"month and "<<day<<" day"<<endl;                   

Getch();

}