C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 6, Problem 15SA
(a)
Program Plan Intro
To give the output of the given
(b)
Program Plan Intro
To explain the working of the program.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include
Servo servo;
int const trigPin = 9;
int const echoPin = 8;
#define red 5
#define green 6
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(red,OUTPUT);
pinMode(green,OUTPUT);
servo.attach(10);
}
void loop()
{
int duration, distance;
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);// Measure the pulse input in echo pin
duration = pulseIn(echoPin, HIGH);// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;// if distance less than 0.5 meter and more than 0 (0 or less means over range)
if (distance = 0)
{
servo.write(60);
digitalWrite(green,HIGH);
digitalWrite(red,LOW);
delay(200);
}
else
{
servo.write(10);
digitalWrite(red,HIGH);
digitalWrite(green,LOW);
delay(80);
}
}
TASK: create a flowchart using this code, showing the input, output and the conditions on the loop. Lastly, the flowchart must return if ever the conditions have met or not
Explain these c++ statements
void bar(int panam) {panam +=1;}
Explain this c++ statement
void bar(int* panam) {*panam +=1;}
Chapter 6 Solutions
C++ Programming: From Problem Analysis to Program Design
Ch. 6 - Mark the following statements as true or false:
a....Ch. 6 - Determine the value of each of the following...Ch. 6 - Determine the value of each of the following...Ch. 6 - Consider the following function definition. (4, 6)...Ch. 6 - Consider the following statements:
Which of the...Ch. 6 - Prob. 8SACh. 6 - Prob. 9SACh. 6 - Why do you need to include function prototypes in...Ch. 6 - Prob. 11SACh. 6 - Consider the following function: (4)...
Ch. 6 - Prob. 15SACh. 6 - What is the output of the following program? (4)
Ch. 6 - Write the definition of a function that takes as...Ch. 6 - Prob. 18SACh. 6 - How would you use a return statement in a void...Ch. 6 - Prob. 20SACh. 6 - Prob. 21SACh. 6 - What is the output of the following program?...Ch. 6 - Write the definition of a void function that takes...Ch. 6 - Write the definition of a void function that takes...Ch. 6 - Prob. 8PECh. 6 - The following formula gives the distance between...Ch. 6 - Write a program that takes as input five numbers...Ch. 6 - When you borrow money to buy a house, a car, or...Ch. 6 - Consider the definition of the function main:...Ch. 6 - The statements in the following program are not in...Ch. 6 - Write a program that outputs inflation rates for...Ch. 6 - Write a program to convert the time from 24-hour...Ch. 6 - Jason opened a coffee shop at the beach and sells...
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
- in C++. (only #include <iostream>)arrow_forwardint main() { E(); C(); E(); } void B() {...} void C() {..} void D() {..} void E() { B(); D(); } A variable declared in function B and only in function B is accessible in?arrow_forward1# Description: This C++ program on TIC TAC TOE GAME is a simple text base game. This program is without graphics to focus on logic /algorithm used in game. Two players can play this game. Player 1 (X> Player 2 (O) 3 4. 9. Player 1, enter a nunber:arrow_forward
- Describe the below c program. #include <stdio.h>#include <stdlib.h> int get_1st_weekday(int year){ int d;d = (((year - 1) * 365) + ((year - 1) / 4) - ((year - 1) / 100) + ((year) / 400) + 1) % 7;return d;} int main(){system("Color 3F");int year,month,day,daysInMonth,weekDay=0,startingDay;printf("\nEnter your desired year:");scanf("%d",&year); char *months[]={"January","February","March","April","May","June","July","August","September","October","November","December"};int monthDay[]={31,28,31,30,31,30,31,31,30,31,30,31}; if((year%4==0&&year%100!=0)||year%400==0)monthDay[1]=29; startingDay=get_1st_weekday(year); for(month=0;month<12;month++){ daysInMonth=monthDay[month];printf("\n\n---------------%s-------------------\n",months[month]);printf("\n Sun Mon Tue Wed Thurs Fri Sat\n"); for(weekDay=0;weekDay<startingDay;weekDay++)printf(" "); for(day=1;day<=daysInMonth;day++){printf("%5d",day); if(++weekDay>6){printf("\n");weekDay=0;}startingDay=weekDay;}…arrow_forwardThis picture must demonstrate array and functions. Code this in C languagearrow_forwardAssignment: Simplifying C Code Description: Reduce the C snippet on the next page to the most basic components possible, as discussed in the lecture. For instance, please try to eliminate the following language components, replacing them only with if/goto blocks: ● for loop while loop ●. switch statement . curly brackets { } (other than those surrounding main) += and -= notation Once complete, test your code and the original code with a few different initial values! Deliverables: Your simplified C code, in a plaintext (.txt) file A screenshot of the simplified code running, showing it produces the same output as the original. Using BF computer language.arrow_forward
- Make this C language code into modular code (functions) #include #include main() { char choice; int num1, num2, result = 0; while(1) { printf("\nEnter Operator(+,-, *, /,f, s):");//f for floor division and s for square root //choice-getch(); scanf("%c",&choice); if(choice=='s') { printf("\nEnter Value to calculate square root:"); scanf("%ld",&num1); } else{ printf("\nEnter First Value:"); scanf("%d",&num1); printf("\nEnter Second Value:"); scanf("%d",&num2); } switch (choice) { case '+': result = num1 + num2; printf("\nSum is = %d", result); break; case '-': result = num1 - num2; printf("\nDifference is = %d", result); printf("\n\nPress Enter Again for New Input\n"); break; case '*': result = num1 * num2; printf("\nProduct is = %d", result); printf("\n\nPress Enter Again for New Input\n"); break; case '/': result = num1 / num2; printf("\nQuotient is = %d", result); printf("\n\nPress Enter Again for New Input\n"); break; case 'f'://floor division result = floor(num1/num2);…arrow_forwardEXPLAIN THIS C++ PROGRAM STEP BY STEP DETAIL WITH LOGIC #include<iostream> using namespace std; class Circle{int x,y;int r;static int number_of_circles;public:Circle(int a , int b, int rad){x = a;y = b;r = rad;++number_of_circles;}Circle(const Circle &c1){x = c1.x;y = c1.y;r = c1.r;number_of_circles = ++c1.number_of_circles; }void display(){cout<<"Co-ordinates : ("<<x<<" , "<<y<<" ) \n";cout<<"Radius : "<<r<<"\n";}friend void update(Circle &c);static int update_number_of_circles(){return number_of_circles;}};void update(Circle &c){int a,b,rad;cout<<"Enter the coordinates of the centre : ";cin>>a>>b;cout<<"Enter the radius of th circle : ";cin>>rad;c.x = a;c.y = b;c.r = rad;}int Circle::number_of_circles = 0; int main(){Circle c(1,2,5);Circle c1(c);Circle c2(c1);c1.display();update(c1);c1.display();cout<<c2.update_number_of_circles(); } #include<iostream> using namespace std;…arrow_forwardMake this C language code into modular code (functions) #include #include main() { char choice; int num1, num2, result = 0; while(1) { printf("\nEnter Operator(+, -, *, /,f, s):");//f for floor division and s for square root //choice=getch(); scanf(" %c",&choice); if(choice=='s'){ printf("\nEnter Value to calculate square root:"); scanf("%ld",&num1); } else{ printf("\nEnter First Value:"); scanf("%d",&num1); printf("\nEnter Second Value:"); scanf("%d",&num2); } switch(choice) { case '+': result = num1 + num2; printf("\nSum is = %d",result); break; case '-': result = num1 - num2; printf("\nDifference is = %d",result); printf("\n\nPress Enter Again for New Input\n"); break; case '*': result = num1 * num2; printf("\nProduct is = %d",result); printf("\n\nPress Enter Again for New Input\n"); break; case '/': result = num1 / num2; printf("\nQuotient is = %d",result); printf("\n\nPress Enter Again…arrow_forward
- Convert this C++ program to pep/9 int main(){ int cop; int driver; cop = 0; driver = 40; while (cop <= driver) { cop += 25; driver += 20; } cout << cop; return 0;} pep/9 source code only pleasearrow_forwardInput Array Name: inp Code in C++arrow_forwardIn C Language, take an infix expression from the user and write a program to check the bracket evaluation of the expression. Do not user pointers and make your code as efficient as possible.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education