Posts

160: Write a program to find the eligibility of admission for a professional course based on the following criteria: Eligibility Criteria: Marks in Math's >= 65 and Marks in Phy >=55 and Marks in Chem>=50

  // Write a program to find the eligibility of admission for a professional course based on the // following criteria: // Eligibility Criteria: Marks in Math's >= 65 and Marks in Phy >=55 and Marks in Chem>=50 #include < iostream > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 22 " << endl           << endl ;     int math , phy , chem ;     cout << " Enter your marks in Maths: " ;     cin >> math ;     cout << " Enter your marks in Physics: " ;     cin >> phy ;     cout << " Enter your marks in Chemisty: " ;     cin >> chem ;     if ( math >= 65 && phy >= 55 && chem >= 50 )     { ...

159: Write a program which takes 4 different number from user as input and display them in ascending and descending order.

  // Write a program which takes 4 different number from user as input and display them in // ascending and descending order. #include < iostream > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 20 " << endl           << endl ;     int num1 , num2 , num3 , num4 , temp ;     cout << " Precaution: All numbers must be unequal " << endl ;     cout << " Enter first number: " ;     cin >> num1 ;     cout << " Enter second number: " ;     cin >> num2 ;     cout << " Enter third number: " ;     cin >> num3 ;     cout << " Enter fourth number: " ;     cin >> num4 ;     // bring greatest ...

158: Write a program which display the sum of whole part and decimal part of a float number. // Input decimal number = 7.8; // Output => 15

  // Write a program which display the sum of whole part and decimal part of a float number // Input decimal number = 7.8; //              Output => 15 #include < iostream > #include < algorithm > #include < string > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 19 " << endl << endl ;     int num ;     string a ;     cout << " Input a decimal number: " ;     cin >> a ;     string b = a ; // saving a for later use     a . erase ( remove ( a . begin (), a . end (), ' . ' ), a . end ());     // Removing point from the string     num = stoi ( a );     // Converting string to int         int sum = 0 ; ...

157: Check if the barcode is valid or not. The final digit of a Universal Product Code is a check digit computed so that sum of the even positions number, plus 3 multiplies with the sum of odd positioned numbers, modulo 10 = 0. // 036000 291452 // For example, in your program take the UPC as 7 digits number i.e. 4708874. The sum of even positioned digits is 7+8+7 = 22, and the sum of the odd-numbered digits is 4+0+8+4 = 16. The total sum is 22+3×16 = 70 = 0 modulo 10. So, the code is valid

  // Check if the barcode is valid or not // The final digit of a Universal Product Code is a check digit computed so that sum of the // even positions number, plus 3 multiplies with the sum of odd positioned numbers, modulo 10 = 0. //        036000  291452 // For example, in your program take the UPC as 7 digits number i.e.  4708874. The sum of even // positioned digits is 7+8+7 = 22, and the sum of the odd-numbered digits is 4+0+8+4 = 16. The total // sum is 22+3×16 = 70 = 0 modulo 10. So, the code is valid #include < iostream > #include < string > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 18 " << endl           << endl ;     string barcode ;     int even_sum = 0 , odd_sum = 0 ;     ...

156: Write a program that inputs a five-digit number from the user, reverses it and determines if the original and reverse numbers are equal or not. Do not allow the user to enter any other number except a five-digit number.

  // Write a program that inputs a five-digit number from the user, reverses it and determines if // the original and reverse numbers are equal or not. Do not allow the user to enter any other number // except a five-digit number. #include < iostream > #include < string > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 17 " << endl           << endl ;     string num ;     do     {         cout << " Enter a 5 digit number: " ;         cin >> num ;     } while ( num . length () != 5 );     int num_ = stoi ( num );     int temp = num_ ;     int reverse = 0 ;     while ( temp > 0 )     {   ...

155: Write a program that converts an integer e.g. 5 to its binary form. Print out binary in the following format: Enter decimal no: 5 Binary is: 101

  // Write a program that converts an integer e.g. 5 to its binary form. // Print out binary in the following format: // Enter decimal no: 5 // Binary is: 101 #include < iostream > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 13 " << endl           << endl ;     int num ;     cout << " Enter decimal no: " ;     cin >> num ;     // getting reverse binary     int temp_rem , temp_binary = 0 ;     while ( num > 0 )     {         temp_rem = num % 2 ;         temp_binary = temp_binary * 10 + temp_rem ;         num = num / 2 ;  // in binary every number is divided by 2 not 10     } ...

154: Write a program that inputs salary and grade. It adds 50% bonus if the grade is greater than 15. It adds 25% bonus if the grade is 15 or less and then display the total salary

  // Write a program that inputs salary and grade. It adds 50% bonus if the grade is greater than // 15. It adds 25% bonus if the grade is 15 or less and then display the total salary #include < iostream > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 12 " << endl           << endl ;     int salary , grade ;     cout << " Enter your salary: Rs. " ;     cin >> salary ;     cout << " Enter your grade: " ;     cin >> grade ;     if ( grade > 15 )     {         cout << " Your total salary is: Rs. " << ( salary + salary * 0.5 ) << endl ;     }     else if ( grade <= 15 && grade ...

153: Write a program to read an amount (integer value) and break the amount into smallest possible number of bank notes. Note: The possible banknotes are 500, 100, 50, 20, 10, 5, 2, and 1

  // Write a program to read an amount (integer value) and break the amount into smallest possible // number of bank notes. Note: The possible banknotes are 500, 100, 50, 20, 10, 5, 2, and 1 #include < iostream > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 11 " << endl           << endl ;     int cash ;     cout << " Enter the amount of cash you have: " ;     cin >> cash ;     int five_hundred = cash / 500 ;     cash = cash % 500 ;     int hundred = cash / 100 ;     cash = cash % 100 ;     int fifty = cash / 50 ;     cash = cash % 50 ;     int twenty = cash / 20 ;     cash = cash % 20 ;     int ten = cas...

152: A bank in your town updates its customers' accounts at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer's balance falls below the minimum balance, there is a service charge of $10.00 for savings accounts and $25.00 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows: a. Savings accounts receive 4% interest. b. Checking accounts with balances of up to $5,000 more than the minimum balance receive 3% // interest; otherwise, the interest is 5%. Write a program that reads a customer's account number (int type), account type (char; s for savings, c for checking), minimum balance that the account should maintain, and current balance. The program should then output the account number, account type, current balance, and an appropriate message. Test your program by running it five times, using the following data: // 46728 S 1000 2700 // 87324 C 1500 7689 // 79873 S 1000 800 // 89832 C 2000 3000 // 98322 C 1000 750

  // A bank in your town updates its customers' accounts at the end of each month. The bank offers // two types of accounts: savings and checking. Every customer must maintain a minimum balance. If // a customer's balance falls below the minimum balance, there is a service charge of $10.00 for // savings accounts and $25.00 for checking accounts. If the balance at the end of the month is at least // the minimum balance, the account receives interest as follows: // a. Savings accounts receive 4% interest. // b. Checking accounts with balances of up to $5,000 more than the minimum balance receive 3% // interest; otherwise, the interest is 5%. // Write a program that reads a customer's account number (int type), account type (char; s for // savings, c for checking), minimum balance that the account should maintain, and current balance. // The  program  should  then  output  the  account  number,  account  type,  current  balance, ...

151: The roots of the quadratic equation ax2 + bx + c = 0, a≠ 0 are given by the following formula: // x = -b ± √(b2 - 4ac) / 2a //In this formula, the term b2 - 4ac is called the discriminant. If b2 - 4ac = 0, then the equation has a single (repeated) root. If b2- 4ac > 0, the equation has two real roots. If b2-4ac < 0, the equation has two complex roots. Write a program that prompts the user to input the value of a (the coefficient of x2 ), b (the coefficient of x), and c (the constant term) and outputs the type of roots of the equation. Furthermore, if b2-4ac = 0, the program should output the roots of the quadratic equation

  // The roots of the quadratic equation ax2 + bx + c = 0, a≠ 0 are given by the following formula: //             x = -b ± √(b2 - 4ac) / 2a // In this formula, the term b2 - 4ac is called the discriminant. If b2 - 4ac = 0, then the equation has // a single (repeated) root. If b2- 4ac > 0, the equation has two real roots. If b2-4ac < 0, the equation // has two complex roots. Write a program that prompts the user to input the value of a (the coefficient // of x2 ),  b (the coefficient of x), and c (the constant term) and outputs the type of roots of the // equation. Furthermore, if b2-4ac = 0, // the program should output the roots of the quadratic equation #include < iostream > #include < cmath > using namespace std ; int main () {     cout << " Muhammad Umar Chaudhry " << endl ;     cout << " SU92-BSCSM-S23-007 " << endl ;     cout << " Question # 9 " <...