C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 4, Problem 4.21E
(What Does this
1. // Exercise 4.21 Mystrey2.cpp
2. #include <iostream>
3. using namespace std;
4.
5. int main () {
6. unsigned int count {1};
7.
8. while (count <= 10) {
9. count << (count % 2==1 ? “&**” : “++++++++”) **lt;< end1;
10. ++count;
11. }
12. }
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q3: (Tax Calculator) Develop a Java program that determines the total tax for each of four citizens. The tax rate is 10% for earnings up to 50,000 RM earned by each citizen and 15% for all earnings in excess of that ceiling. You are given a list with the citizens’ names and their earnings in a given year. Your program should input this information for each citizen, then determine and display the citizen’s total tax. Use class Scanner to input the data.
[In C#] Write an application named SumInts that allows the user to enter any number of integers continuously until the user enters 999. Display the sum of the values entered, not including 999.
using System;
using static System.Console;
class SumInts
{
static void Main()
{
// Write your main here.
}
}
1)
#include
#include
int power(int, int);
int main(void)
{
int x, n;
printf("Enter a number and powerto raise it to: ");
scanf_s("%d %d", &x, &n);
printf("Result: %d\n", power(n, x));
return 0;
}
int power(int x, int n)
{
int m;
if (n == 0) return 1;
if (n % 2 == 0) {
m = power(x, n / 2);
return m * m;
}
else return x * power(x, n - 1);
}
2)
#include
int hcf(int n1, int n2);
int main()
{
int n1, n2;
printf("Enter any two positive integers: ");
scanf("%d %d", &n1, &n2);
printf("Greatest Common Divisor of %d and %d is %d.", n1, n2, hcf(n1,n2));
return 0;
}
int hcf(int n1, int n2)
{
if (n2 != 0)
return hcf(n2, n1%n2);
else
return n1;
}
3)
#include
int main()
{
int array[], minimum, size, c, location = 1;
printf("Enter the number of elements in array\n");
scanf("%d",&size);
printf("Enter %d integers\n", size);
for ( c = 0 ; c < size ; c++ )
scanf("%d", &array[c]);
minimum = array[0];
for ( c = 1 ; c < size ; c++ )
{
if ( array[c] < minimum )
{…
Chapter 4 Solutions
C++ How to Program (10th Edition)
Ch. 4 - (Correct the Code Errors) Identity and correct the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - For Exercises 4.13—4.16, perform each of these...Ch. 4 - (Find the largest) The process of finding the...Ch. 4 - (Tabular Output) Write a C++ program that uses a...Ch. 4 - (Find the Two Largest Numbers) Using an approach...Ch. 4 - (Validating User Input) The examination-results...
Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (What Does this Program Do?) What does the...Ch. 4 - (Dangling-else Problem)C++ compliers always...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Square of Asterisks) Write a program that reads...Ch. 4 - (Palindromes) A palindrome is a number or a text...Ch. 4 - (Printing the Decimal Equivalent of a Binary...Ch. 4 - (Checkerboard Pattern of Asterisks) W rite a...Ch. 4 - (Multiples of 2 with an Infinite Loop) write a...Ch. 4 - (Calculating a Circle’s Diameter, circumference...Ch. 4 - What’s wrong with the following statement? Provide...Ch. 4 - (Sides of a Triangle) Write a program that reads...Ch. 4 - (Sides of a Right Triangle) Write a program that...Ch. 4 - (Factorial) The factorial of a nonnegative integer...Ch. 4 - (Modified Account Class) Modify class Account...Ch. 4 - (Enforcing Privacy with Cryptography) The...Ch. 4 - (World Population Growth) World population has...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- DO NOT COPY FROM OTHER WEBSITES Correct and detailed answer will be Upvoted else downvoted. Thank you!arrow_forward(a) #include using namespace std; int main() { } for(int i = 0; i <=30; cout << i*2 << endl; } return 0; ){ Output: 0 20 40 60arrow_forwardvoid main (void) { char result = a; for (char i = { 10; i > 5; i = i-1) result = result + i; } // point B } Consider the code above. What is the decimal value of "result" at "point B" if the variable "a" is initially 59?arrow_forward
- 1-)Can you improve this code for a 2-digit number? For instance, 27 means twenty-seven? #include <stdio.h>#include <stdlib.h> int main() {int a;printf("Enter a integer number :");scanf("%d",&a); switch(a){case 0:printf("ZERO");break;case 1:printf("ONE");break;case 2:switchprintf("TWO");break;case 3:printf("THREE");break;case 4:printf("FOUR");break;case 5:printf("FIVE");break;case 6:printf("SIX");break;case 7:printf("SEVEN");break;case 8:printf("EIGHT");break;case 9:printf("NINE");break; } }arrow_forward(save as io_ex3.cpp) #include using namespace std; int main () { clrscr(); char ch; ch = 'A'; cout<arrow_forward7) ( )If we define variables: int a=2, b-4, c=6; the value of the following expression ((a> b? a: b) > c)? (a> b? a: b): c; is: A) 2 B) 8 C) 4 D) 6arrow_forward(write a pseudocode or draw a flowchart of the given program below) #include<iostream>#include<string.h>using namespace std; class staff{public:string Name;char NoIC[13];int Age;int Category;int Scheme;}; int main(){int n=2;staff s[n];for(int i=0;i<n;i++){cout<<"Enter Name ";cin>>s[i].Name;cout<<"Enter Number Ic ";cin>>s[i].NoIC;cout<<"Enter Age ";cin>>s[i].Age;cout<<"Enter Category(1 for Academic / 2 for Non-Academic) ";cin>>s[i].Category;cout<<"Enter Scheme (1 for Pension on 56 years / 2 for Pension on 60 years) ";cin>>s[i].Scheme;}cout<<endl;cout<<"Staff's Information"<<endl;cout<<"Name\t\tNoIC\t\tAge\tCategory\tScheme"<<endl;for(int i=0;i<n;i++){cout<<s[i].Name<<"\t\t";cout<<s[i].NoIC<<"\t";cout<<s[i].Age<<"\t";if(s[i].Category==1)cout<<"Academic"<<"\t";else…arrow_forward(Java) Q 5,6 Explain the answer step-by-step . I want to understand how to do it so please include verbal explanation. Thank you! Part 1 Write the class described below: The name of the class is Student The class has two public member variables: A String called name and a double called gpa The class has a public member method called printStudent. This method prints out the message: "Hi! My name is " + name + ".\nAnd my gpa is " + gpa It returns nothing Part 2 Now, declare a new Student object named jackie, and assign it the values "Jackie Chan" for the name and 3.5 for the gpa. Finally insert the object jackie into the below ArrayList: ArrayList<Student> al = new ArrayList<Student>();arrow_forwardFind the error in the following code and explain how to fix it: #include int main(void) int *ptr; int m 100; ptr = m; printf("%d",*ptr);arrow_forwardc++ onlyarrow_forward(CLO3) Read the following description and answer the following questions about it: Problem Description: A car dealership allows customer to purchase their new cars with different options. At this time, those options are color, model, and air condition, as shown below in class CustomerOrder. Of course, the dealership wants the software to be flexible enough to be able to add more options in the future, if needed. CustomerOrder -carColor: String -carModel: String -hasAirCondition: boolean Q1) Write the full required code in Java to use the Builder design pattern to create class CustomerOrder. Q2) Write a Java main() method to create an object of class CustomerOrder with color "red" and without air condition.arrow_forward1:1 E.pdf Q/ write C++ program to create class called grades that has data members Degl, Deg2, and Deg3, also has a constructor to assign values, and another constructor to reset values, also method to display values, and method to find the subtraction of grades.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License