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
Concept explainers
Question
-
int tab[5];
for(int i = 4;i>=0;i--)
{
tab[i] = 4 - i;
cout<<tab[i]<<" ";
}
-
4 3 2 0 1
-
0 1 2 4 4
-
0 1 2 3 4
-
1 1 2 2 3
-
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
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
- #include <iostream> #include <iomanip> #include <string> #include <vector> using namespace std; class Movie { private: string title = ""; int year = 0; public: void set_title(string title_param); string get_title() const; // "const" safeguards class variable changes within function string get_title_upper() const; void set_year(int year_param); int get_year() const; }; // NOTICE: Class declaration ends with semicolon! void Movie::set_title(string title_param) { title = title_param; } string Movie::get_title() const { return title; } string Movie::get_title_upper() const { string title_upper; for (char c : title) { title_upper.push_back(toupper(c)); } return title_upper; } void Movie::set_year(int year_param) { year = year_param; } int Movie::get_year() const { return year; } int main() { cout << "The Movie List program\n\n"…arrow_forwardint sum = 0; for (int i 0; i < 5; i++){ sum += i; } cout << sum;arrow_forwardMatch the C-function on the left to the Intel assemble function on the right. W: cmpl $4 movl %edi , %edi jmp .L4(,%rdi,8) %edi .L3: movl $17, %eax ret .15: movl $3, %eax int A ( int x , int y) { int a ; if ( x == 0 ) else i f ( x == 1 ) a = 3 ; else i f ( x == 2 ) a = 2 0 ; else i f ( x == 3 ) a = 2 ; else i f ( x == 4 ) a = 1 ; ret .L6: a = 17; movl $20, %eax ret .L7: movl $2, %eax ret else a = 0; .L8: return a ; movl $1, %eax .L2: ret . section .rodata . L4: .quad .L3 .quad .L5 .quad .L6 .quad .L7 .quad .L8 X: testl %edi, %edi je cmpl je cmpl je стр1 je cmpl .L16 $1, %edi .L17 $2, %edi .L18 $3, %edi int B (int x, int y) { int a; switch (x) { .L19 $4, %edi %al movzbl %al, %eax case 0: a = 17; break; sete break; case 1: a = 3; case 2: a = 20; break; case 3: a = 2; break; case 4: a = 1; a = 0; } return a; ret .L16: break; movl $17, %eax ret .L17: movl $3, %eax } ret .L18: movl $20, %eax ret .L19: movl ret $2, %eaxarrow_forward
- // Program 1#include <iostream>using namespace std;int main (){ cout << " i j" <<endl; cout << "----------" <<endl; int Array1[ 5 ]; // Array1 is an array of 5 integers for ( int i = 0; i < 5; i++ ) // initialize elements of array i to 0 { Array1[i] = i + 1; // Array1[i] + 1 cout <<"\n "<< i <<" "<< Array1[i] ; // Display i & Array[i] cout <<"\n"; }return 0; } // Program 2#include <iostream>using namespace std;int main (){ cout << " i Array[i]" <<endl; cout << "----------------" <<endl; int Array1[ 5 ]; // Array1 is an array of 5 integers for ( int i = 0; i < 5; i++ ) // initialize elements of array i to 0 { Array1[i] = i + 1; // Array1[i] + 1 cout <<"\n "<< i <<" "<< Array1[i] ; // Display i & Array[i] for ( int j = 0; j < 5; j++ ) { Array1[j] = j + 2; cout <<"\n "<< j <<" "<< Array1[j] ; // Display j & Array[j] } cout…arrow_forwardC++ What is the output? int columns;int rows;for (rows = 0; rows < 2; ++rows) { for (columns = 0; columns < 3; ++columns) { cout<<"x"; } cout<<endl;;}arrow_forward#include <iostream>#include <iomanip>#include <cmath>using namespace std; double findHypotenuse(double side1, double side2){ double h = sqrt((side1 * side1) + (side2 * side2 )); return h;} int main(){ int side1; int side2; cin >> side1; cin >> side2; cout << fixed << showpoint; cout << setprecision(2); cout << "Hypotenuse: "; cout << findHypotenuse(side1, side2)<< endl; return 0;} ---trying to make this accpet user input but cannot make it work, if i can get assistance that would be amazing thank youarrow_forward
- #include <stdio.h> #include <stdlib.h> #include <string.h> #define EMPS_SIZE 20 #define SSN_SIZE 9 #define MAX_EMPS 19 typedef struct { int salary; int yearBorn; char ssn[SSN_SIZE]; char * name; } Employee; Employee * emps[EMPS_SIZE]; int totalEmps = 0; void main(void) { int end = 1; char * command; char buff[256]; char * findEmp; char findBuff[256]; char * sortType; char sortBuff[256]; char hire[] = "HIRE"; char list[] = "LIST"; char quit[] = "QUIT"; char find[] = "FIND"; char fire[] = "FIRE"; char _sort[] = "SORT"; char salary[] = "SALARY"; char name[] = "NAME"; char save[] = "SAVE"; printf("Welcome to the Employee Manager dashboard!\n"); while (end) { printf("Would you like to HIRE, LIST, FIND, FIRE, SORT,SAVE or QUIT?\n\n"); scanf("%s", buff); command = malloc(strlen(buff + 1)); strcpy(command, buff); printf("You entered the command: %s\n\n", command);…arrow_forward#include #include #include 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, y Point2d add(const Point2d &other) const { Point2d result; result.x = x + other.x; result.y = y + other.y; return result; } }; // // do NOT modify above this line // Point2d discplacement(std::string commands) { // TODO: re-write this Point2d p = {0, 0}; return p; } // // do NOT modify below this line // void check(Point2d result, double x , double y) { if (result.x != x || result.y != y) { std::cout << "fail" << std::endl; } else { std::cout << "pass" << std::endl; } } int main() { Point2d result =…arrow_forward#include <iostream>#include <string>#include <climits> using namespace std;class BalancedTernary { protected: // Store the value as a reversed string of +, 0 and - characters string value; // Helper function to change a balanced ternary character to an integer int charToInt(char c) const { if (c == '0') return 0; return 44 - c; } // Helper function to negate a string of ternary characters string negate(string s) const { for (int i = 0; i < s.length(); ++i) { if (s[i] == '+') s[i] = '-'; else if (s[i] == '-') s[i] = '+'; } return s; } public: // Default constructor BalancedTernary() { value = "0"; } // Construct from a string BalancedTernary(string s) { value = string(s.rbegin(), s.rend()); } // Construct from an integer BalancedTernary(long long n) { if (n == 0) { value = "0"; return; } bool neg = n < 0; if (neg) n = -n; value = ""; while (n !=…arrow_forward
- 1. Implement a class IntArr using dynamic memory. a. data members: capacity: maximum number of elements in the array size: current number of elements in the array array: a pointer to a dynamic array of integers b. constructors: default constructor: capacity and size are 0, array pointer is nullptr user constructor: create a dynamic array of the specified size c. overloaded operators: subscript operator: return an element or exits if illegal index d. "the big three": copy constructor: construct an IntArr object using deep copy assignment overload operator: deep copy from one object to another destructor: destroys an object without creating a memory leak e. grow function: "grow" the array to twice its capacity f. push_back function: add a new integer to the end of the array g. pop_back function: remove the last element in the array h. getSize function: return the current size of the array (not capacity) i. Use the provided main function (next page) and output example Notes a. grow…arrow_forward#include <iostream>#include <cstdlib>#include <time.h>#include <chrono> using namespace std::chrono;using namespace std; void randomVector(int vector[], int size){ for (int i = 0; i < size; i++) { //ToDo: Add Comment vector[i] = rand() % 100; }} int main(){ unsigned long size = 100000000; srand(time(0)); int *v1, *v2, *v3; //ToDo: Add Comment auto start = high_resolution_clock::now(); //ToDo: Add Comment v1 = (int *) malloc(size * sizeof(int *)); v2 = (int *) malloc(size * sizeof(int *)); v3 = (int *) malloc(size * sizeof(int *)); randomVector(v1, size); randomVector(v2, size); //ToDo: Add Comment for (int i = 0; i < size; i++) { v3[i] = v1[i] + v2[i]; } auto stop = high_resolution_clock::now(); //ToDo: Add Comment auto duration = duration_cast<microseconds>(stop - start); cout << "Time taken by function: " << duration.count()…arrow_forwardC++ complete and create magical square #include <iostream> using namespace std; class Vec {public:Vec(){ }int size(){return this->sz;} int capacity(){return this->cap;} void reserve( int n ){// TODO:// (0) check the n should be > size, otherwise// ignore this action.if ( n > sz ){// (1) create a new int array which size is n// and get its addressint *newarr = new int[n];// (2) use for loop to copy the old array to the// new array // (3) update the variable to the new address // (4) delete old arraydelete[] oldarr; } } void push_back( int v ){// TODO: if ( sz == cap ){cap *= 2; reserve(cap);} // complete others } int at( int idx ){ } private:int *arr;int sz = 0;int cap = 0; }; int main(){Vec v;v.reserve(10);v.push_back(3);v.push_back(2);cout << v.size() << endl; // 2cout << v.capacity() << endl; // 10v.push_back(3);v.push_back(2);v.push_back(3);v.push_back(4);v.push_back(3);v.push_back(7);v.push_back(3);v.push_back(8);v.push_back(2);cout…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