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
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Implement in C Programming
7.11.1: LAB: Student struct
Given main(), build a struct called Student that represents a student that has two data members: the student's name (string) and the student's GPA (double). Assume student's name has a maximum length of 20 characters.
Implement the Student struct and related function declarations in Student.h, and implement the related function definitions in Student.c as listed below:
Student InitStudent() - initializes name to "Louie" and gpa to 1.0
Student SetName(char *name, Student s) - sets the student's name
Student SetGPA(double gpa, Student s) - sets the student's GPA
void GetName(char* studentName, Student s) - return the student's name in studentName
double GetGPA(Student s) - returns the students GPA
Ex. If a new Student object is created, the default output is:
Louie/1.0
Ex. If the student's name is set to "Felix" and the GPA is set to 3.7, the output becomes:
Felix/3.7
main.c
#include <stdio.h>
#include <string.h>…
Complete the code for infinite list variables in Haskell, which contains the variables "a" through "z", then repeats these suffixed with 1, "a1",...,"z1", then 2, "a2",...,"z2", etc.
example - *Main> [variables !! i | i <- [0,1,25,26,27,100,3039]] ["a","b","z","a1","b1","w3","x116"].
Describe a situation where the add operator in a programming languagewould not be commutative.
____________________________________________________________________
Let the function fun be defined asint fun(int *k) { *k += 4; return 3 * (*k) – 1;}Suppose fun is used in a program as follows:void main(){ int i = 10, j = 10, sum1, sum2;sum1 = (i/2) + fun(&i);sum2 = fun(&j) + (j/2);}What are the values of sum1 and sum2a. if the operands in the expressions are evaluated left to the right?b. if the operands in the expressions are evaluated right to the left?
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
- Implement in C Programming 6.10.1: Function pass by pointer: Transforming coordinates. Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew. The function returns void. The transformation is new = (old + 1) * 2. Ex: If xVal = 3 and yVal = 4, then xValNew is 8 and yValNew is 10. #include <stdio.h> /* Your solution goes here */ int main(void) { int xValNew; int yValNew; int xValUser; int yValUser; scanf("%d", &xValUser); scanf("%d", &yValUser); CoordTransform(xValUser, yValUser, &xValNew, &yValNew); printf("(%d, %d) becomes (%d, %d)\n", xValUser, yValUser, xValNew, yValNew); return 0;}arrow_forward- Pure Javascript in console- Use camelCase- use functions to call each case- all cases must be user inputarrow_forwardDescribe the performance considerations when heavily utilizing function objects.arrow_forward
- I know how set and function works ... but i just dont know how do i implement it on a C++ program.. here is the question that i have problem with a) User need add input for set A, B and Relation b) Add at least 2 operation of sets such as intersection, union, and etc. c) Add at least 2 operation of function such as transistive, symetric and etc. d) Write a program that able to pick any one of four options(TWO operation of set and TWO operation of relation) example of the outputarrow_forwardMUST BE DONE IN C - Allow the user to enter multiple pairs of x and y coordinates on a 2 dimensional graph (these numbers may be considered unitless) along with a text label for that set of points. You must use a "struct" data type to define how these are stored. - The x and y coordinates should be type "float" or "double" - Allow multiple data points to be entered by the user, so the first thing the user must ask is how many coordinates will be entered. Since multiple entries will be made you must create an array of that "struct" type. - Once all of the coordinates and labels are entered, calculate the distance between each set of points (you DO NOT have to store all of the distances!!!). In this lab you may use "math.h" (it may be useful). - Determine which coordinates are closest to each other out of all of the pairs. - Determine which coordinates are furthest from each other out of all of the pairs. NOTE!!!! There will be a 10 point value for efficiency. Please contemplate the BEST…arrow_forward6. In Java, you have the opportunity to either use a predefined function/method or write a user-defined function/method. In this discussion, provide at least three criteria that would be used to develop an appropriate method of your choice and the rationale behind the selection of these criteria.arrow_forward
- Implement in C Programming 6.10.2: Pass by pointer. Write a function call to ConvertMoney() to store the number of quarters, nickels, and pennies within the integer variables numQuarters, numNickels, and numPennies, respectively. Ex: If the input is 133, then the output is: Quarters: 5 Nickels: 1 Pennies: 3 #include <stdio.h> void ConvertMoney(int totalPennies, int* numQuarters, int* numNickels, int* numPennies) { *numQuarters = totalPennies / 25; totalPennies = totalPennies % 25; *numNickels = totalPennies / 5; totalPennies = totalPennies % 5; *numPennies = totalPennies;} int main(void) { int totalPennies; int numQuarters; int numNickels; int numPennies; scanf("%d", &totalPennies); /* Your code goes here */ printf("Quarters: %d\n", numQuarters); printf("Nickels: %d\n", numNickels); printf("Pennies: %d\n", numPennies); return 0;}arrow_forwardwrite a C++ program. Write a program that calculates and displays the average of a group of test scores, all integers, after the lowest score in the group has been dropped. There are six test scores in the group. The program must contain only the following functions in additionto the main:• void getScore should ask the user for a test score, store it in a referenceparameter variable, and validate it. This function should be called by the mainfunction once for of the six scores to be entered by the user.• double calcAverage should calculate and return the average of the five highest scores. This function should be called just once by the main function, and should be passed the six scores. Use pass by reference to receive the lowest test score.• int findLowest should find and return the lowest of the six scores passed to it. It must be called by the calcAverage function, which uses it to determine which of the six scores to drop.• void displayResults should be called by the main function…arrow_forwardin Haskell: rewrite the following function in two different ways: 1. as a sequence of transformations using the explicit application operator ($) 2. as a composition of functions using the "dot" composition operator (.) stringToInt s = reverse [ord x - 48 | x <- s] stringToIntRec x (head : tail) = (x * head) + (stringToIntRec' (x*10) tail) stringToIntRec x [] = []arrow_forward
- EXPLAIN THIS C++ PROGRAM STEP BY STEP WITH LOGIC #include<iostream>using namespace std;class Circle{private: //To Store center (x,y) and radius r double x,y,r; static int number_of_circles;public: //parameterized constructor Circle(double x1,double y1,double r1){ x=x1; y=y1; r=r1; update_number_of_circles(); } //Copy constructor Circle(Circle &c){ x=c.x; y=c.y; r=c.r; update_number_of_circles(); } //member function to display the values x,y,r void display(){ cout<<"Center : ("<<x<<" , "<<y<<") Radius : "<<r<<endl; } static void update_number_of_circles(){ number_of_circles++; } static int get_number_of_circles(){ return number_of_circles; } friend void updateCircle(double x,double y,double r,Circle &c){ c.x=x; c.y=y; c.r=r; }};int Circle::number_of_circles=0;int main(){…arrow_forwardidentify the following as better representing static or dynamic binding. a) an int is an int forever and ever amen b) 2/2.0 = 1.0 c) 3/2.0 -> error message d) binding is done at compile time e) binding is slower but more flexiblearrow_forwardProblem 6: Induction and Recursion Consider a postal system for which the minimum postage required for any service (e.g. mailing a postcard) is 18 cents. [a] Prove by strong induction that any postage ≥ 18 can be formed using only 4-cent and 7-cent stamps. (Hint: consider bases cases for 18 thru 21.) [b] Write a Java/Python-like pseudocode for a function that determines the number of each denomination of stamp for a postage amount ≥ 18. (It need not be concerned with lesser cases as they are never used).arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_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
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License