0% found this document useful (0 votes)
4 views

for_zu_2

The document outlines a series of programming tasks and examples primarily focused on C++ programming concepts. It includes exercises for calculating PIN entry attempts, printing odd and even numbers, handling palindromes, calculating averages, and developing programs for various practical applications like mileage tracking and credit limit checks. Additionally, it provides pseudocode and C++ code snippets for implementing these tasks.

Uploaded by

zgtrkzxcmz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

for_zu_2

The document outlines a series of programming tasks and examples primarily focused on C++ programming concepts. It includes exercises for calculating PIN entry attempts, printing odd and even numbers, handling palindromes, calculating averages, and developing programs for various practical applications like mileage tracking and credit limit checks. Additionally, it provides pseudocode and C++ code snippets for implementing these tasks.

Uploaded by

zgtrkzxcmz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

When the program asks you to Enter your PIN:, try the following: you can enter password 3 times.
Press 1111 and press enter.
Press 2019 and press enter.
Press 1234 and press enter.
2. Print all odd numbers from a to b(a<b)
3. Print all even numbers from a to b(a<b)
4. The count of all even and odd numbers from a to b (a<b) display
5. Display all 2-digit numbers with the same digits
6. Display all 2-digit numbers with different digits
7. Display all 2-digit numbers where ones and tens are equal
8. Display all 2-digit numbers where ones more than ten.
9. Display the numbers from a to b ending in x or y
10. Display all 3-digit numbers with different digits from 100 to 200
11. From 100 to 200, display all 3-digit numbers with at least 2 digits that are equal.
12. Display all 3-digit numbers from 100 to 300 where the decimal is at least 2 units greater than
the hundredth.
13. Find the two largest values among the 10 numbers. Note: You must input each number only
once.
14. Print following program

15. A palindrome is a number or a text phrase that reads the same backwards as forwards. For
example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and
11611. Write a program that reads in a five-digit integer and determines whether it is a
palindrome. (Hint: Use the division and modulus operators to separate the number into its
individual digits.)
16. Write a program that calculates and prints the average of several integers. Assume the last
value read is the sentinel 9999. A typical input sequence might be indicating that the average of
all the values preceding 9999 is to be calculated
10 8 11 7 9 9999
.
Difficult
1. Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track
of several tankfuls of gas-oline by recording miles driven and gallons used for each tankful.
Develop a C++ program that will input the miles driven and gallons used for each tankful. The
program should calculate and display the miles per gallon obtained for each tankful. After
processing all input information, the program should calculate and print the combined miles per

gallon obtained for all tankfuls.


2. Develop a C++ program that will determine if a department store customer has exceeded the
credit limit on a charge account. For each customer, the following facts are available:
a) Account number (an integer)
b) Balance at the beginning of the month
c) Total of all items charged by this customer this month
d) Total of all credits applied to this customer's account this month
e) Allowed credit limit
The program should input each of these facts, calculate the new balance (= beginning balance +
charges – credits) and deter-mine if the new balance exceeds the customer's credit limit. For those
customers whose credit limit is exceeded, the program should display the customer's account
number, credit limit, new balance and the message “Credit limit exceeded”.
3. Develop a C++ program that will determine the gross pay for each of several employees. The
company pays “straight-time”
for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked
in excess of 40 hours. You are given a list of the employees of the company, the number of hours
each employee worked last week and the hourly rate of each employee. Your program should
input this information for each employee and should determine and display the employee's gross
pay.

4. The process of finding the largest number (i.e., the maximum of a group of numbers) is used
frequently in computer applications. For example, a program that determines the winner of a
sales contest would input the number of units sold by each sales-person. The salesperson who
sells the most units wins the contest. Write a pseudocode program, then a C++ program that
inputs a series of 10 numbers, and determines and prints the largest of the numbers. Hint: Your
program should use three variables, as follows:
counter: A counter to count to 10 (i.e., to keep track of how many numbers have been input and
to determine when all 10 numbers have been processed).
number: The current number input to the program.
largest: The largest number found so far.
5. A company wants to transmit data over the telephone, but they are concerned that their phones
may be tapped. All of their data are transmitted as four-digit integers. They have asked you to
write a program that encrypts their data so that it can be transmitted more securely. Your program
should read a four-digit integer and encrypt it as follows: Replace each digit by (the sum of that
digit plus 7) modulus 10. Then, swap the first digit with the third, swap the second digit with the
fourth and print the encrypted integer. Write a separate program that inputs an encrypted four-
digit integer and decrypts it to form the original number.
17.
1. Answer
#include <iostream>

using namespace std;

int main()
{
int password,tries=1;

while (password!=1234)
{
cout<<"ënter your password "<<endl;
cin>>password;
if(tries==3)
{
cout<<"You can not write password again"<<endl;
break;
}

tries++;
}
if(password==1234)
{
cout<<"your accepted";
}
return 0;
}
2. int main()
{
int a;
cout<<"Enter a ";
cin>>a;
int b;
cout<<"Enter b ";
cin>>b;

for(int i=a;i<=b;i++)
{
if(i%2==0)
cout<<i<<endl;
}
return 0;
}
3. #include <iostream>

using namespace std;

int main()
{
int a;
cout<<"Enter a ";
cin>>a;
int b;
cout<<"Enter b ";
cin>>b;
int count_odd=0;
int count_even=0;
for(int i=a;i<=b;i++)
{
if(i%2==0)
count_odd++;
else
count_even++;
}
cout<<"count_odd= "<<count_odd<<endl;
cout<<"count_even= "<<count_even<<endl;
return 0;
}
4.---------------------------------------------------------------------------

You might also like