Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.4, Problem 2.53PP
Practice Problem 2.53 (solution page 160)
Fill in the following macro definitions to generate the double-precision values + ∞, –∞, and –0:
#define POS_INFINITY
#define NEG_INFINITY
#define NEG_ZERQ
You cannot use any include files (such as math. h), but you can make use of the fact that the largest finite number that can be represented with double precision is around 1.8× 10308.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question #2:
(5 Points).
Write a function in C++ which accepts a 2D array of
integers and its size as arguments and displays
the elements of middle row and the elements of
middle column.
[Assuming the 2D Array to be a square matrix
with odd dimension i.e. 3x3, 5x5, 7x7 etc...]
Example, if the array contents is
3 5 4
7 6 9
2 1 8
Output through the function should be :
Middle Row :769
Middle column : 5 6 1
Question
1
Not yet
answered
Marked out of
1.00
Time left 0:29:54
Write a C++ function, smallestIndex, that takes as parameters an and its size and returns the index
of the first occurrence of the smallest element in the array. Also, write a program to test your
function.
You need:
1) Print the elements of the array
2) Show the index of the first smallest element of the array
3) Show the smallest element in the array
4
Enter 15 Integers:
538264839428945
538264839428945
The position of the first occurrence of the smallest element in list is: 3
The smallest element in list is: 2
SA
Sultan Al Ghafri
130139
Finish attempt...
Task - Encode a string (C Language)
Modify Project #2, Task #1 (given below) so that input characters are command line arguments.
Requirements
Name your program project5_encode.c.
Input characters are command line arguments. There can be any number of command line arguments.
Assume the total number of input characters is no more than 1000.
Character handling library functions in ctype.h are allowed.
The program should include the following function:
void encode(char *input, char *output);
The function expects input to point to a string containing the string to be encoded, output to point to a string containing the result.
The program should also check if the number of arguments on the command line is greater than or equal to 2. If the number of arguments is 1, the program should display the message "Invalid input!".
Examples (your program must follow this format precisely)
Example #1
$ ./a.out 7 + 8Output: 3_4
Example #2
$ ./a.out usf.eduOutput: ayl_kja
Example #3
$…
Chapter 2 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 2.1 - Practice Problem 2.1 (solution page 143) Perform...Ch. 2.1 - Prob. 2.2PPCh. 2.1 - Prob. 2.3PPCh. 2.1 - Practice Problem 2.4 (solution page 144) Without...Ch. 2.1 - Prob. 2.5PPCh. 2.1 - Prob. 2.6PPCh. 2.1 - Prob. 2.7PPCh. 2.1 - Prob. 2.8PPCh. 2.1 - Practice Problem 2.9 solution page 146 Computers...Ch. 2.1 - Prob. 2.10PP
Ch. 2.1 - Prob. 2.11PPCh. 2.1 - Prob. 2.12PPCh. 2.1 - Prob. 2.13PPCh. 2.1 - Prob. 2.14PPCh. 2.1 - Prob. 2.15PPCh. 2.1 - Prob. 2.16PPCh. 2.2 - Prob. 2.17PPCh. 2.2 - Practice Problem 2.18 (solution page 149) In...Ch. 2.2 - Prob. 2.19PPCh. 2.2 - Prob. 2.20PPCh. 2.2 - Prob. 2.21PPCh. 2.2 - Prob. 2.22PPCh. 2.2 - Prob. 2.23PPCh. 2.2 - Prob. 2.24PPCh. 2.2 - Prob. 2.25PPCh. 2.2 - Practice Problem 2.26 (solution page 151) You are...Ch. 2.3 - Prob. 2.27PPCh. 2.3 - Prob. 2.28PPCh. 2.3 - Prob. 2.29PPCh. 2.3 - Practice Problem 2.30 (solution page 153) Write a...Ch. 2.3 - Prob. 2.31PPCh. 2.3 - Practice Problem 2.32 (solution page 153) You are...Ch. 2.3 - Prob. 2.33PPCh. 2.3 - Prob. 2.34PPCh. 2.3 - Practice Problem 2.35 (solution page 154) You are...Ch. 2.3 - Prob. 2.36PPCh. 2.3 - Practice Problem 2.37 solution page 155 You are...Ch. 2.3 - Prob. 2.38PPCh. 2.3 - Prob. 2.39PPCh. 2.3 - Practice Problem 2.40 (solution page 156) For each...Ch. 2.3 - Prob. 2.41PPCh. 2.3 - Practice Problem 2.42 (solution page 156) Write a...Ch. 2.3 - Practice Problem 2.43 (solution page 157) In the...Ch. 2.3 - Prob. 2.44PPCh. 2.4 - Prob. 2.45PPCh. 2.4 - Prob. 2.46PPCh. 2.4 - Prob. 2.47PPCh. 2.4 - Prob. 2.48PPCh. 2.4 - Prob. 2.49PPCh. 2.4 - Prob. 2.50PPCh. 2.4 - Prob. 2.51PPCh. 2.4 - Prob. 2.52PPCh. 2.4 - Practice Problem 2.53 (solution page 160) Fill in...Ch. 2.4 - Practice Problem 2.54 (solution page 160) Assume...Ch. 2 - Compile and run the sample code that uses...Ch. 2 - Try running the code for show_bytes for different...Ch. 2 - Prob. 2.57HWCh. 2 - Write a procedure is_little_endian that will...Ch. 2 - Prob. 2.59HWCh. 2 - Prob. 2.60HWCh. 2 - Prob. 2.61HWCh. 2 - Write a function int_shifts_are_arithmetic() that...Ch. 2 - Fill in code for the following C functions....Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: /...Ch. 2 - Write code to implement the following function: / ...Ch. 2 - You are given the task of writing a procedure...Ch. 2 - Prob. 2.68HWCh. 2 - Write code for a function with the following...Ch. 2 - Write code for the function with the following...Ch. 2 - You just started working for a company that is...Ch. 2 - You are given the task of writing a function that...Ch. 2 - Write code for a function with the following...Ch. 2 - Write a function with the following prototype: /...Ch. 2 - Prob. 2.75HWCh. 2 - The library function calloc has the following...Ch. 2 - Prob. 2.77HWCh. 2 - Write code for a function with the following...Ch. 2 - Prob. 2.79HWCh. 2 - Write code for a function threefourths that, for...Ch. 2 - Prob. 2.81HWCh. 2 - Prob. 2.82HWCh. 2 - Prob. 2.83HWCh. 2 - Prob. 2.84HWCh. 2 - Prob. 2.85HWCh. 2 - Intel-compatible processors also support an...Ch. 2 - Prob. 2.87HWCh. 2 - Prob. 2.88HWCh. 2 - We are running programs on a machine where values...Ch. 2 - You have been assigned the task of writing a C...Ch. 2 - Prob. 2.91HWCh. 2 - Prob. 2.92HWCh. 2 - following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Following the bit-level floating-point coding...Ch. 2 - Prob. 2.97HW
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Look at the following code, which is the first line of a class definition: public class Tiger extends Felis In ...
Starting Out with Java: Early Objects (6th Edition)
Write a program to print the value of EOF.
C Programming Language
Define each of the following terms: entity type entity-relationship model entity instance Attribute relationshi...
Modern Database Management (12th Edition)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Roman Numerals Design a program that prompts the user to enter a number within the range of 1 through 10. The p...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
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
- 2-[10p]Write flowing formula (R,n,S (double) and returning value of function) C function function that calculate the a are input V(double) output 1 2 V ==R/3. V5 [a-you can use math.h library]arrow_forward[Python (py3)] Using import numpy as np, import sys, and def functions Please create a code that solves for matrix addition, matrix scalar multiplication, and matrix multiplication The input will come from file1.txt, and the output should be printed to output.txt Note for matrix addition: When the dimension of Matrix A is not equal to the dimension of Matrix B, print "Matrix addition cannot be performed; dimensions are unequal." Note for matrix multiplication: When the number of columns of Matrix A is not equal to the number of rows of Matrix B, print "Matrix multiplication cannot be performed; number of columns of Matrix A is not equal to number of rows of Matrix B." Format of the input from file1.txt:First Line: type of operation (add or scalmultiply or multiply)Second Line: matrix A dimension (example: if 3 rows and 2 columns, type 3 2)Third Line: matrix A elementsFourth Line: matrix B dimension (or the scalar number for the operation of scalar multiplication)Fifth Line: matrix B…arrow_forwardC++ Programming. Topic: Working with pointers and dynamic memory. Indicators. Working with dynamic memory. Dynamic arrays and their use as function parameters. Task : Describe a void function named Swap(x,y) that swaps the values stored in the variables x and (x is a real type parameter and is both input and output). Using this function , for the given variables of real type a, b, c, d, one should sequentially replace the values of the pairs (a, b), (c, d) and (b, c) and let a, b, c, d be new values .arrow_forward
- Q1)There are 10 boxes of apples arranged in a row, assume the values have been stored in an arrayaryBox. Use C code to write a C program segment to find out which box is having the most number of applesas compared to other boxes. A sample output is as follow:Box number 5 contains the most number of apple.[Note: You need to declare all the necessary variables and use an efficient way to representthe data as well as solving the problem]arrow_forwardComplete/Modify the code satisfying the following: (put comments pls) in C++, pls put comments in the code 1. Create a 10x10 matrix using rand function to fill the said matrix with random numbers 2. Print all the numbers in matrix form 3. Ask the user the following options here are the options A. Sum per row B. Sum per column C. Display all ODD numbers horizontally D. Display all EVEN numbers horizontally E. Display all PRIME numbers horizontally F. Generate new set of random numbers G. Close the program After asking what option to display, Display again the previous numbers entered and the same options. Here's the code: #include<stdio.h>#include<math.h> main(){ char rep; rep = 'y'; while(rep=='y'||rep =='Y') { int cntr01=1,xsum=0,numrow,numcol; char option; int x[3][3]; //creates --> x[0][0],x[0][1],x[0][2] //creates --> x[1][0],x[1][1],x[1][2] //creates --> x[2][0],x[2][1],x[2][2] //cntr01++ <-->…arrow_forwardC++ Problem 1) Find how many non-zero element are in a matrix (two-dimensional array)- use as an example: 10 -4 0 7 8 3 0 0 1 Read the values from input (cin) using for loops and use for loops to find the answer. C++arrow_forward
- Example 7: Code the below problem using C++ Sample Input: 1. 4 1234 Sample Output: 16 Ayush has an array a of n integers. He wants to collapse the entire array into a single element. To do this, he can perform the operation described below any number of times. Each operation grants some points, and Ayush's total score will be the sum of the points granted over all operations he performs. Let aſi..j] denote the subarray of a starting at index i and ending at j. Define min; j to be the minimum value in a[i..j]. In one operation he can do the following: • Select any subarray a[i. j] of a of size at least 2 and replace this subarray by a single element equal to the sum of elements of the subarray. The number of points granted by such an operation, which will be added to his total score, is (j – i+1) · min;j. For example, consider an array a = [2, 3, 5]. If he selects the subarray a[1..2], his total score increases by 2 · 2 = 4 points. Now a = [5, 5]. Ayush performs operations until only a…arrow_forwardUsing c++ Q:3 (a) You are supposed to make three arrays of integer type data, array 1 having size m, array 2 having size n and array 3 of size m+n. Input in array 1 and array2. Assuming that data entered in array 1 will be in ascending order and data entered in array 2 will be in descending order. You have to fill array 3 in such a way that data in array is placed in ascending order.arrow_forwardObjectives: practice with math, while-loops, sentinels, input validation, functions Starting with the provided file circles.py, write a program that uses functions to compute the area and circumference of a circle of a user-specified radius. The program consists of a main () function and two other functions, as follows: main (): Asks the user for the radius of a circle (floating point number). If the user enters a radius of zero, the program prints “Goodbye!" and ends. If the user enters a negative radius, the program prints “Invalid radius!", and asks again for a radius, and keeps asking until the user enters zero or a positive number. If the user enters a positive number, the program calls the two other functions and prints: A circle of radius R has circumference C and area A. (where R is the radius number, C is the calculated circumference, and A is the calculated area.) After printing the circumference and area, the program asks again for a new radius. [20 pts] circumference (r) :…arrow_forward
- c++ (1) Create a function capable of multiplying a row of a matrix by a given number. Do the same for a columnarrow_forwardQ) Develop a computer program in F90 to form the matrix A (n, n) which contains reals. The program finds and prints the sum and average of elements of the triangle above the minor diagonal. Use subroutine subprogram to find the required sum.arrow_forwardQ5 (a) What is the data type of pointer variables? Suppose that we don't know the name of a variable but we do know its address. Can we access the contents of that variable? Explain briefly. (b) Write a program which defines three integer variables, varl, var2 and var3, & initializing them to the values 100, 200 & 300, it then prints out their addresses. Needed code in C++ Only part Barrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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