I want these programs in c++ 1. Write a program that asks the user to enter two
ID: 3677906 • Letter: I
Question
I want these programs in c++
1. Write a program that asks the user to enter two numbers. The program should use the conditional operator/expression to determine which number is the smaller and which is the larger of the two. [2 points]
2. Write a program that asks the user to enter a number within the range of numbers equivalent to the lowercase alphabet. Use a switch statement to display the alphabet version of that number. [5 points]
3. Create a change-counting game that asks the user to enter what coins to use to make exactly one dollar. The program should ask the user to enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins inserted is equal to one dollar the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more or less than one dollar. Use constant variables to hold the coin values. [5 points]
4. Write code that lets the user enter a number and a letter. Both should be increased until the end of the alphabet is reached and printed. Use a while loop. [3 points]
6. Write a program that finds and prints all of the prime numbers between 3 and 100. A prime number is a number that can only be divided by one and itself (i.e. 3, 5, 7, 11, 13...) [5 points]
Hint: One way to solve this problem is to use a doubly nested loop. The outer loop can iterate from 3 to 100, while the inner loop checks to see whether the counter value for the outer loop is prime. One way to decide whether the number n is prime is to loop from 2 to n-1; if any of these numbers evenly divides n, then n cannot be prime. If none of the values from 2 to n-1 evenly divide n, then n must be prime.
Explanation / Answer
#include<stdio.h>
int smallestlargest(int x, int y, int z)
{
int c = 0;
while ( x && y && z )
{
x--; y--; z--; c++;
}
return c;
}
int main()
{
int x = 12, y = 15, z = 5;
printf("Minimum of 3 numbers is %d", smallest(x, y, z));
printf("Minimum of 3 numbers is %d", largest(x, y, z));
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.