for_zu_2
for_zu_2
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
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>
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>
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.---------------------------------------------------------------------------