Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
>> IN C PROGRAMMING LANGUAGE ONLY <<
COPY OF DEFAULT CODE, ADD SOLUTION INTO CODE IN C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GVDie.h"
int RollSpecificNumber(GVDie die, int num, int goal) {
/* Type your code here. */
}
int main() {
GVDie die = InitGVDie(); // Create a GVDie variable
die = SetSeed(15, die); // Set the GVDie variable with seed value 15
int num;
int goal;
int rolls;
scanf("%d", &num);
scanf("%d", &goal);
rolls = RollSpecificNumber(die, num, goal); // Should return the number of rolls to reach total.
printf("It took %d rolls to get a \"%d\" %d times.\n", rolls, num, goal);
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
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
- C 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_forwardC++ compile a program to answer question in picture included. Code to edit: #include <iostream> #include <string> class DayOfYear{ private: mutable int day; // Make 'day' mutable // Static arrays to hold month names and the number of days in each month static const std::string monthNames[]; static const int daysInMonth[]; public: // Constructor DayOfYear (int day) : day (day) {} // Member function to print the day in month-day format void print () const { int tempDay = day; // Create a temporary variable int month = 0; // Find the month for the given day while (tempDay > daysInMonth[month]) { tempDay -= daysInMonth[month]; month++; } // Print the result std::cout << monthNames[month] << " " << tempDay << std::endl; }}; // Static member variable initialization const std::string DayOfYear::monthNames[] = { "January", "February", "March", "April", "May", "June",…arrow_forwardC++ programming task. main.cc file: #include <iostream>#include <map>#include <vector> #include "plane.h" int main() { std::vector<double> weights{3.2, 4.7, 2.1, 5.5, 9.8, 7.4, 1.6, 9.3}; std::cout << "Printing out all the weights: " << std::endl; // ======= YOUR CODE HERE ======== // 1. Using an iterator, print out all the elements in // the weights vector on one line, separated by spaces. // Hint: see the README for the for loop syntax using // an iterator, .begin(), and .end() // ========================== std::cout << std::endl; std::map<std::string, std::string> abbrevs{{"AL", "Alabama"}, {"CA", "California"}, {"GA", "Georgia"}, {"TX", "Texas"}}; std::map<std::string, double> populations{ {"CA", 39.2}, {"GA", 10.8}, {"AL", 5.1}, {"TX", 29.5}}; std::cout <<…arrow_forward
- C++ This program does not compile! Spot the error and give the line number. Presume that the header file is error free and // Implementation file for the Rectangle class.1. #include "Rectangle.h" // Needed for the Rectangle class2. #include <iostream> // Needed for cout3. #include <cstdlib> // Needed for the exit function4. using namespace std; //***********************************************************// setWidth sets the value of the member variable width. *//*********************************************************** 5. void Rectangle::setWidth(double w){6. if (w >= 0)7. width = w;8. else{9. cout << "Invalid width\n";10. exit(EXIT_FAILURE);}} //***********************************************************// setLength sets the value of the member variable length. *//*********************************************************** 11. void Rectangle::setLength(double len){12. if (len >= 0)13. length = len;14. else{15. cout << "Invalid length\n";16.…arrow_forwardC++ program #include<iostream> #include<fstream> #include<string> using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; struct Customers { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode; char isDeleted; char newLine; }; void add_data(int no_of_records, ofstream& fout) { struct Customers c; cout << "Enter the Customer data:" << endl; cout << "Name:"; cin >> c.name; cout << "Street Address 1:"; cin >> c.streetAddress_1; cout << "Street Address 2:"; cin >> c.streetAddress_2; cout << "City:"; cin >> c.city; cout << "State:"; cin >> c.state; cout << "Zip Code:"; cin >> c.zipCode; cout << endl; c.customerNumber = no_of_records; c.isDeleted = 'N'; c.newLine = '\n'; cout…arrow_forward#include <iostream> #include <string> #include <cstdlib> using namespace std; template<class T> class A { public: T func(T a, T b){ return a/b; } }; int main(int argc, char const *argv[]) { A <float>a1; cout<<a1.func(3,2)<<endl; cout<<a1.func(3.0,2.0)<<endl; return 0; } Give output for this code.arrow_forward
- in C code not c++arrow_forwardThis is the C code I have so far #include <stdio.h> #include <stdlib.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; // function to read the employee data from the user void readEmployee(struct employees *emp) { printf("Enter name: "); gets(emp->name); printf("Enter ssn: "); for (int i = 0; i < 9; i++) scanf("%d", &emp->ssn[i]); printf("Enter birth year: "); scanf("%d", &emp->yearBorn); printf("Enter salary: "); scanf("%d", &emp->salary); } // function to create a pointer of employee type struct employees *createEmployee() { // creating the pointer struct employees *emp = malloc(sizeof(struct employees)); // function to read the data readEmployee(emp); // returning the data return emp; } // function to print the employee data to console void display(struct employees *e) { printf("%s", e->name); printf(" %d%d%d-%d%d-%d%d%d%d",…arrow_forwardin C++ starting code: #include <iostream>// FIXME include vector libraryusing namespace std; int main() { /* Type your code here. */ return 0;} Please copy and paste working code.arrow_forward
- C++ code. Please describe what EACH line means/does. Ignore code that is commented out.arrow_forwardC++ shapes.h: #include <iostream>#include <cmath>struct Point2d{double x;double y;void print(){// example: (2.5,3.64)std::cout << "(" << x << "," << y << ")" << std::endl;}double length() const{return std::sqrt(x * x + y * y);}// const Point2D & ==> function can't modify 'other'// the second const ==> function can't modify x, yPoint2d add(const Point2d &other) const{Point2d result;result.x = x + other.x;result.y = y + other.y;return result;}};// example of an interfacestruct Shape{virtual bool contains(Point2d p) = 0;};struct Circle : Shape{Point2d center;double radius;bool contains(Point2d p){Point2d diff;diff.x = p.x - center.x;diff.y = p.y - center.y;double distToCenter = diff.length();return distToCenter <= radius;}};// TODO: replace this with your Rectangle implementationstruct Rectangle : Shape{// TODO: which member variables to model a rectangle?bool contains(Point2d p){return false; // TODO }};//…arrow_forwardC programming fill in the following code #include "graph.h" #include <stdio.h>#include <stdlib.h> /* initialise an empty graph *//* return pointer to initialised graph */Graph *init_graph(void){} /* release memory for graph */void free_graph(Graph *graph){} /* initialise a vertex *//* return pointer to initialised vertex */Vertex *init_vertex(int id){} /* release memory for initialised vertex */void free_vertex(Vertex *vertex){} /* initialise an edge. *//* return pointer to initialised edge. */Edge *init_edge(void){} /* release memory for initialised edge. */void free_edge(Edge *edge){} /* remove all edges from vertex with id from to vertex with id to from graph. */void remove_edge(Graph *graph, int from, int to){} /* remove all edges from vertex with specified id. */void remove_edges(Graph *graph, int id){} /* output all vertices and edges in graph. *//* each vertex in the graphs should be printed on a new line *//* each vertex should be printed in the following format:…arrow_forward
arrow_back_ios
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