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
Description
Develop a C program that computes the different roots in a quadratic equation, ax + bX?=0.
r= -b ± v (b? – 4ac) , rl is the root when the + is used in the equation and r2 is the root when
2a
the – is used. The roots r1 and r2 can only be computed when the discriminant
(b - 4ac) is greater than the zero else the quadratic equation does not have any roots and therefore the
program should display "no roots".
NOTE: sąrt is a built in function in C to extract the roots. The program will prompt to input the values of a, b
and c and output the roots r1 and r2 or no roots at all. Check your answer manually.
Sample Output if Applicable
CT 0:Ruel Lauron\C_Programs\QUAD.exe
Enter the value of a:1
Enter the value of b:-3
Enter the value of c:-10
The value of x1 is 5.00
The value of x2 is -2.00
Explain these c++ statements
void bar(int panam) {panam +=1;}
Sub: Data structure
Consider the following 'C’ routine
int DO ( int a[ ], int /b, int ub)
{
int temp;
if( /b == ub)
return a[lb];
else
{
temp =DO( a, Ib+1, ub);
if (a[/b]<= temp);
return a[/b];
else
return temp;
}
What does DO(a,0,5) return if
a[ ] = {0, –1,10,12,5,8};
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
- Explain this C code line per line please #include <stdio.h> #include <malloc.h> void printArray(int**, int); int main() { int i = 0, j = 0, n = 5; int **arr = (int**)malloc(n * sizeof(int*)); for(int i=0;i<n;i++){ *(arr+i) = (int*)malloc(n*sizeof(int)); } for(i=0;i<n;i++){ for(int j=0;j<n;j++){ *(*(arr+i) + j) = 0; } } printArray(arr, n); for(i=0;i<n;i++){ *( *(arr + i) + i) = i+1; } printArray(arr,n); return 0; } void printArray(int ** array, int size) { int i,j; for(i = 0;i<size;i++){ for(j=0;j<size;j++){ printf("%d ", *( *(array + i) + j)); } printf("\n"); } printf("\n"); }arrow_forwardC programming #include <stdio.h>int main() {int i, j, n ;printf("height? ") ;scanf("%2d", &n) ;for (i = 1 ; i <= n ; i++) {// printf("%d: ", i) ;for (j = 1 ; j <= i ; j++) {// Pick *one* of the following// printf("%d", j % 10) ;printf("*") ;}printf("\n") ;}return 0 ;} How can I get output like this by editing the given programming -- height? 5************************* and then how can I get the following?- height? 7 1 123 12345 1234567 123456789 12345678901 1234567890123arrow_forwardWrite the reccurence relation for the following function (in C-style code) void T(n){ if(n>1){ int j; for(j = n; j>1; j = j/2); T(n/2); T(n/2); } }arrow_forward
- refer to the statment below:arrow_forwardPlease explainarrow_forwardDescribe 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_forward
- C++ PROGRAMMING PART C Please help me i am stressing so much on this. I would really appreciate it. THIS was the code provided to me to help me solve the question. const int N =31; // N parking spaces bool parking[N]; // the garage void EmptyTheLot(bool parking[], int N) { for(int i=0; i<N; i++) p[i]=false; // empty space } // returns -1 if no space found, //otherwise it returns 0<=i<N for a valid space. int FindSpace(int PlateNumber, bool parking[], int N) { // ????? } main() { EmptyTheLot(parking, N); // start with an empty parking garage. // get plate numbers and fill lot. }arrow_forwardc++/data structuresarrow_forwardThe statement int arr[size]; in the following C++ codc in Figure 5 produces an error. This is due to the size of array cannot be initialized dynamically. Thus, constant expression is required. int main () { int size, i; cin>>size; int arr[size); for (i=1; ic=size; i++) { cin>> arr[i]; cout <<"You entered : "<< arr[i]; system ("pause"); return 0; } Figure 5 Answer : Reason :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