Questions
Modify programming problem 4 from Assignment 2. You will create a number of threads—for example, 100—and...

Modify programming problem 4 from Assignment 2. You will create a number of threads—for example, 100—and each thread will request a pid, sleep for a random period of time, and then release the pid. (Sleeping for a random period of time approximates the typical pid usage in which a pid is assigned to a new process, the process executes and then terminates, and the pid is released on the process's termination.) On UNIX and Linux systems, sleeping is accomplished through the sleep() COMP2004 Assignment 3 & Assignment 4 Fall 2020 function, which is passed an integer value representing the number of seconds to sleep.

HERE IS MY CODE:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MIN_PID 300
#define MAX_PID 5000

typedef struct node {
int pid;
struct node* next;
}Node;

int allocate_map(void);
int allocate_pid(void);
void release_pid(int pid);
int i;
Node *head;
/*
main function tests all three functions
*/
int main(){
allocate_map();
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
release_pid(301);
printf("allocated pid: %d\n",allocate_pid());
allocate_map();
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
printf("allocated pid: %d\n",allocate_pid());
release_pid(305);
release_pid(30);

}

int allocate_map(void){
if(i>0){
return -1;
}
head = malloc(sizeof(Node));
Node *curr = head;
for(i=0;i<MAX_PID-MIN_PID;i++){
curr->pid = 0;
curr->next = (i<(MAX_PID-MIN_PID)) ? malloc(sizeof(Node)):NULL;
curr = curr->next;
}

return 1;
}
int allocate_pid(void){
if(head->next == NULL){
return -1;
}

int i = MIN_PID +1 ;

Node *iter = head;
if(head->pid == 0){
head->pid = MIN_PID;
return head->pid;
}
while(iter ->next->pid !=0 && i<MAX_PID){
iter = iter->next;
i++;
}
if(i<MAX_PID ){

iter->next->pid = i;
return iter->next->pid;
}
else{return -1;}
}

void release_pid(int pid){
if(head->next == NULL && head->pid==0){
printf("Nothing to release\n");
return;
}
else if(pid<MIN_PID || pid>MAX_PID){
printf("invalid release\n");
return;
}
if(head->pid==pid){
head->pid=0;
}
Node *iter = head;
while(iter->next !=NULL){
if(iter->next->pid==pid){
iter->next->pid=0;
return;
}
iter = iter->next;
}
printf("Nothing to release\n");
}

In: Computer Science

Program Behavior This program will analyze real estate sales data stored in an input file. Each...

Program Behavior

This program will analyze real estate sales data stored in an input file. Each run of the program should analyze one file of data. The name of the input file should be read from the user.

Here is a sample run of the program as seen in the console window. User input is shown in blue:

Let's analyze those sales!

Enter the name of the file to process? sales.txt

Number of sales: 6

Total: 2176970

Average: 362828

Largest sale: Joseph Miller 610300

Smallest sale: Franklin Smith 199200

Now go sell some more houses!

Your program should conform to the prompts and behavior displayed above. Include blank lines in the output as shown.

Each line of the data file analyzed will contain the buyer's last name, the buyer's first name, and the sale price, in that order and separated by spaces. You can assume that the data file requested will exist and be in the proper format.

The data file analyzed in that example contains this data:

Cochran Daniel 274000
Smith Franklin 199200
Espinoza Miguel 252000
Miller Joseph 610300
Green Cynthia 482370
Nguyen Eric 359100

You can download that sample data file here https://drive.google.com/file/d/1bkW8HAvPtU5lmFAbLAJQfOLS5bFEBwf6/view?usp=sharing to test your program, but your program should process any data file with a similar structure. The input file may be of any length and have any filename. You should test your program with at least one other data file that you make.

Note that the average is printed as an integer, truncating any fractional part.

Your program should include the following functions:

read_data - This function should accept a string parameter representing the input file name to process and return a list containing the data from the file. Each element in the list should itself be a list representing one sale. Each element should contain the first name, last name, and purchase price in that order (note that the first and last names are switched compared to the input file). For the example given above, the list returned by the read_data function would be:

[['Daniel', 'Cochran', 274000], ['Franklin', 'Smith', 199200], ['Miguel', 'Espinoza', 252000], ['Joseph', 'Miller', 610300], ['Cynthia', 'Green', 482370], ['Eric', 'Nguyen', 359100]]

Use a with statement and for statement to process the input file as described in the textbook.

compute_sum - This function should accept the list of sales (produced by the read_data function) as a parameter, and return a sum of all sales represented in the list.

compute_avg - This function should accept the list of sales as a parameter and return the average of all sales represented in the list. Call the compute_sum function to help with this process.

get_largest_sale - This function should accept the list of sales as a parameter and return the entry in the list with the largest sale price. For the example above, the return value would be ['Joseph', 'Miller', 610300].

get_smallest_sale - Like get_largest_sale, but returns the entry with the smallest sale price. For the example above, the return value would be ['Franklin', 'Smith', 199200].

Do NOT attempt to use the built-in functions sum, min, or max in your program. Given the structure of the data, they are not helpful in this situation.

main - This function represents the main program, which reads the file name to process from the user and, with the assistance of the other functions, produces all output. For this project, do not print output in any function other than main.

Other than the definitions of the functions described above, the only code in the module should be the following, at the end of the file:

if __name__ == '__main__':
main()

That if statement keeps your program from being run when it is initially imported into the Web-CAT test environment. But your program will run as normal in Thonny. Note that there are two underscore characters before and after name and main.

Include an appropriate docstring comment below each function header describing the function.

Do NOT use techniques or code libraries that have not been covered in this course.

Include additional hashtag comments to your program as needed to explain specific processing.

A Word about List Access

A list that contains lists as elements operates the same way that any other lists do. Just remember that each element is itself a list. Here's a list containing three elements. Each element is a list containing integers as elements:

my_list = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]

So my_list[0] is the list [1, 2, 3, 4] and my_list[2] is [9, 10, 11, 12].

Since my_list[2] is a list, you could use an index to get to a particular value. For instance, my_list[2][1] is the integer value 10 (the second value in the third list in my_list).

In this project, the sales list is a list of lists. When needed, you can access a particular value (first name, last name, or sales price) from a particular element in the sales list.

In: Computer Science

Course: Computer Architecture (Theme: Input-Output) A computer consists of a processor and an I/O device D...

Course: Computer Architecture (Theme: Input-Output)

  1. A computer consists of a processor and an I/O device D connected to main memory M via a shared bus with a data bus width of one word. The processor can execute a max of 2 MIPS. An average instruction requires 5 machine cycles, 3 of which use the memory bus. A memory read/write operation uses 1 m/c cycle. Suppose that the processor is continuously executing “background” programs that require 96% of the instruction rate but not any I/O instructions. Assume that one processor cycle equals one bus cycle. Now suppose the I/O device is used to transfer very large amounts of data between M and D.
    1. If programmed I/O is used and each one word transfer requires the processor to execute 3 instructions, estimate the max I/O data transfer rate in words/sec possible through D?
    2. Estimate the same rate if DMA is used?

In: Computer Science

\ Implement function find_key that takes a dictionary with int:int pairs and a second parameter which...

\

Implement function find_key that takes a dictionary with int:int pairs and a second parameter which is an int that corresponds to one of the dictionary values, and returns the key that corresponds to this value. If there are more than one keys, it returns the smallest key. If there is no key that maps to this value, the functions returns False. You may not use the .values and .items methods. You may not create lists, tuples, strings, sets, dictionaries. You maynot use functions min, max, sorted.

Examples:

find_key({5:7, 6:3, 2:1, 3:4}, 4) ->    3

find_key({1:9, 7:4, 6:3, 2:1, 8:4}, 4)    ->    7

find_key({9:5, 6:3, 2:1, 3:3}, 4)       ->    False

True

False

In python Please

In: Computer Science

Design a class named BankAccount that contains: A private int data field named id for the...

Design a class named BankAccount that contains: A private int data field named id for the account. A private double data field named balance for the account. A constructor that creates an account with the specified id and initial balance. A getBalance() method that shows the balance. A method named withdraw that withdraws a specified amount from the account. Create a subclass of the BankAccount class named ChequingAccount. An overdraftlimit to be 1000 for ChequingAccount . Test your ChequingAccount class by constructing a ChequingAccount object with id as 10020, and balance as 1000, and show the result of withdrawing 200 from the chequing account. it should be in java

In: Computer Science

1) Write a C++ program.You will code a movie search/filter console GUI with various operations. The...

1) Write a C++ program.You will code a movie search/filter console GUI with various operations.
The objectives you have to accomplish are listed below;

* Create a Movie Class with private id(int),name(string),point(float),year(int) variables
* Generate Getter for all variables and Setter for only point variable.
* Read the "movie.txt" file and store each movie in Movie array.
* Write necessary functionalities for the GUI options given in below;

Welcome to the Movie Market. Please select an option.
a - Get movie details by ID
b - List movies between the years entered
c - Change the point of a movie
d- Get movie details starting with the entered letter
e - Exit

* Write a "printMovie" function to print movie details
* Use "autoIncrement" logic to set ID values for Movie

Bonus:
Add a "voting system" functionality for movies.
* A movie can be voted up to 10 times with integer values between 1 and 10
* The "point" value of the movie should be equal to the average of votes.
* Be careful when you calculate the average
(If a movie is voted for the first time, the average is (original point value + new vote value) / 2 )

-MOVİES-
9.2;The Shawshank Redemption (1994)
9.1;The Godfather (1972)
9.0;The Godfather: Part II (1974)
8.9;Il buono, il brutto, il cattivo. (1966)
8.9;Pulp Fiction (1994)
8.9;Inception (2010)
8.9;Schindler's List (1993)
8.9;12 Angry Men (1957)
8.8;One Flew Over the Cuckoo's Nest (1975)
8.8;The Dark Knight (2008)
8.8;Star Wars: Episode V - The Empire Strikes Back (1980)
8.8;The Lord of the Rings: The Return of the King (2003)
8.8;Shichinin no samurai (1954)
8.7;Star Wars (1977)
8.7;Goodfellas (1990)
8.7;Casablanca (1942)
8.7;Fight Club (1999)
8.7;Cidade de Deus (2002)
8.7;The Lord of the Rings: The Fellowship of the Ring (2001)
8.7;Rear Window (1954)
8.7;C'era una volta il West (1968)
8.7;Raiders of the Lost Ark (1981)
8.7;Toy Story 3 (2010)
8.7;Psycho (1960)
8.7;The Usual Suspects (1995)
8.7;The Matrix (1999)
8.6;The Silence of the Lambs (1991)
8.6;Se7en (1995)
8.6;Memento (2000)
8.6;It's a Wonderful Life (1946)
8.6;The Lord of the Rings: The Two Towers (2002)
8.6;Sunset Blvd. (1950)
8.6;Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb (1964)
8.6;Forrest Gump (1994)
8.6;Léon (1994)
8.6;Citizen Kane (1941)
8.6;Apocalypse Now (1979)
8.6;North by Northwest (1959)
8.6;American Beauty (1999)
8.5;American History X (1998)
8.5;Taxi Driver (1976)
8.5;Terminator 2: Judgment Day (1991)
8.5;Saving Private Ryan (1998)
8.5;Vertigo (1958)
8.5;Le fabuleux destin d'Amélie Poulain (2001)
8.5;Alien (1979)
8.5;WALL·E (2008)
8.5;Lawrence of Arabia (1962)
8.5;The Shining (1980)
8.5;Sen to Chihiro no kamikakushi (2001)
8.5;Paths of Glory (1957)
8.5;A Clockwork Orange (1971)
8.5;Double Indemnity (1944)
8.5;To Kill a Mockingbird (1962)
8.5;The Pianist (2002)
8.4;Das Leben der Anderen (2006)
8.4;The Departed (2006)
8.4;M (1931)
8.4;City Lights (1931)
8.4;Aliens (1986)
8.4;Eternal Sunshine of the Spotless Mind (2004)
8.4;Requiem for a Dream (2000)
8.4;Das Boot (1981)
8.4;The Third Man (1949)
8.4;L.A. Confidential (1997)
8.4;Reservoir Dogs (1992)
8.4;Chinatown (1974)
8.4;The Treasure of the Sierra Madre (1948)
8.4;Modern Times (1936)
8.4;Monty Python and the Holy Grail (1975)
8.4;La vita è bella (1997)
8.4;Back to the Future (1985)
8.4;The Prestige (2006)
8.4;El laberinto del fauno (2006)
8.4;Raging Bull (1980)
8.3;Nuovo Cinema Paradiso (1988)
8.3;Singin' in the Rain (1952)
8.3;Some Like It Hot (1959)
8.3;The Bridge on the River Kwai (1957)
8.3;Rashômon (1950)
8.3;All About Eve (1950)
8.3;Amadeus (1984)
8.3;Once Upon a Time in America (1984)
8.3;The Green Mile (1999)
8.3;Full Metal Jacket (1987)
8.3;Inglourious Basterds (2009)
8.3;2001: A Space Odyssey (1968)
8.3;The Great Dictator (1940)
8.3;Braveheart (1995)
8.3;Ladri di biciclette (1948)
8.3;The Apartment (1960)
8.3;Up (2009)
8.3;Der Untergang (2004)
8.3;Gran Torino (2008)
8.3;Metropolis (1927)
8.3;The Sting (1973)
8.3;Gladiator (2000)
8.3;The Maltese Falcon (1941)
8.3;Unforgiven (1992)
8.3;Sin City (2005)
8.3;The Elephant Man (1980)
8.3;Mr. Smith Goes to Washington (1939)
8.3;Oldeuboi (2003)
8.3;On the Waterfront (1954)
8.3;Indiana Jones and the Last Crusade (1989)
8.3;Star Wars: Episode VI - Return of the Jedi (1983)
8.3;Rebecca (1940)
8.3;The Great Escape (1963)
8.3;Die Hard (1988)
8.3;Batman Begins (2005)
8.3;Mononoke-hime (1997)
8.2;Jaws (1975)
8.2;Hotel Rwanda (2004)
8.2;Slumdog Millionaire (2008)
8.2;Det sjunde inseglet (1957)
8.2;Blade Runner (1982)
8.2;Fargo (1996)
8.2;No Country for Old Men (2007)
8.2;Heat (1995)
8.2;The General (1926)
8.2;The Wizard of Oz (1939)
8.2;Touch of Evil (1958)
8.2;Per qualche dollaro in più (1965)
8.2;Ran (1985)
8.2;Yôjinbô (1961)
8.2;District 9 (2009)
8.2;The Sixth Sense (1999)
8.2;Snatch. (2000)
8.2;Donnie Darko (2001)
8.2;Annie Hall (1977)
8.2;Witness for the Prosecution (1957)
8.2;Smultronstället (1957)
8.2;The Deer Hunter (1978)
8.2;Avatar (2009)
8.2;The Social Network (2010)
8.2;Cool Hand Luke (1967)
8.2;Strangers on a Train (1951)
8.2;High Noon (1952)
8.2;The Big Lebowski (1998)
8.2;Hotaru no haka (1988)
8.2;Kill Bill: Vol. 1 (2003)
8.2;It Happened One Night (1934)
8.2;Platoon (1986)
8.2;The Lion King (1994)
8.2;Into the Wild (2007)
8.2;There Will Be Blood (2007)
8.1;Notorious (1946)
8.1;Million Dollar Baby (2004)
8.1;Toy Story (1995)
8.1;Butch Cassidy and the Sundance Kid (1969)
8.1;Gone with the Wind (1939)
8.1;Sunrise: A Song of Two Humans (1927)
8.1;The Wrestler (2008)
8.1;The Manchurian Candidate (1962)
8.1;Trainspotting (1996)
8.1;Ben-Hur (1959)
8.1;Scarface (1983)
8.1;The Grapes of Wrath (1940)
8.1;The Graduate (1967)
8.1;The Big Sleep (1946)
8.1;Groundhog Day (1993)
8.1;Life of Brian (1979)
8.1;The Gold Rush (1925)
8.1;The Bourne Ultimatum (2007)
8.1;Amores perros (2000)
8.1;Finding Nemo (2003)
8.1;The Terminator (1984)
8.1;Stand by Me (1986)
8.1;How to Train Your Dragon (2010)
8.1;The Best Years of Our Lives (1946)
8.1;Lock, Stock and Two Smoking Barrels (1998)
8.1;The Thing (1982)
8.1;The Kid (1921)
8.1;V for Vendetta (2006)
8.1;Casino (1995)
8.1;Twelve Monkeys (1995)
8.1;Dog Day Afternoon (1975)
8.1;Ratatouille (2007)
8.1;El secreto de sus ojos (2009)
8.1;Gandhi (1982)
8.1;Star Trek (2009)
8.1;Ikiru (1952)
8.1;Le salaire de la peur (1953)
8.1;Les diaboliques (1955)
8.1;8½ (1963)
8.1;The Princess Bride (1987)
8.1;The Night of the Hunter (1955)
8.0;Judgment at Nuremberg (1961)
8.0;The Incredibles (2004)
8.0;Tonari no Totoro (1988)
8.0;The Hustler (1961)
8.0;Good Will Hunting (1997)
8.0;The Killing (1956)
8.0;In Bruges (2008)
8.0;The Wild Bunch (1969)
8.0;Network (1976)
8.0;Le scaphandre et le papillon (2007)
8.0;A Streetcar Named Desire (1951)
8.0;Les quatre cents coups (1959)
8.0;La strada (1954)
8.0;The Exorcist (1973)
8.0;Children of Men (2006)
8.0;Stalag 17 (1953)
8.0;Persona (1966)
8.0;Who's Afraid of Virginia Woolf? (1966)
8.0;Ed Wood (1994)
8.0;Dial M for Murder (1954)
8.0;La battaglia di Algeri (1966)
8.0;Låt den rätte komma in (2008)
8.0;All Quiet on the Western Front (1930)
8.0;Big Fish (2003)
8.0;Magnolia (1999)
8.0;Rocky (1976)
8.0;La passion de Jeanne d'Arc (1928)
8.0;Kind Hearts and Coronets (1949)
8.0;Fanny och Alexander (1982)
8.0;Mystic River (2003)
8.0;Manhattan (1979)
8.0;Barry Lyndon (1975)
8.0;Kill Bill: Vol. 2 (2004)
8.0;Mary and Max (2009)
8.0;Patton (1970)
8.0;Rosemary's Baby (1968)
8.0;Duck Soup (1933)
8.0;Festen (1998)
8.0;Kick-Ass (2010)
8.0;Fa yeung nin wa (2000)
8.0;Letters from Iwo Jima (2006)
8.0;Roman Holiday (1953)
8.0;Pirates of the Caribbean: The Curse of the Black Pearl (2003)
8.0;Mou gaan dou (2002)
8.0;The Truman Show (1998)
8.0;Crash (2004/I)
8.0;Hauru no ugoku shiro (2004)
8.0;His Girl Friday (1940)
8.0;Arsenic and Old Lace (1944)
8.0;Harvey (1950)
8.0;Le notti di Cabiria (1957)
8.0;Trois couleurs: Rouge (1994)
8.0;The Philadelphia Story (1940)
8.0;A Christmas Story (1983)
8.0;Sleuth (1972)
8.0;King Kong (1933)
8.0;Bom yeoreum gaeul gyeoul geurigo bom (2003)
8.0;Rope (1948)
8.0;Monsters, Inc. (2001)
8.0;Tenkû no shiro Rapyuta (1986)
8.0;Yeopgijeogin geunyeo (2001)
8.0;Mulholland Dr. (2001)
8.0;The Man Who Shot Liberty Valance (1962)

In: Computer Science

Using tkinter, create a GUI interface which accepts input of annual income. Using the table below,...

Using tkinter, create a GUI interface which accepts input of annual income.

Using the table below, determine and output the income tax for that income. Tax Rate Income 10% $0 to $9,875.00;  12% $9,876.01 to $40,125.00; 22% $40,126 to $85,525.00; 24% $85,526.01 to $163,300.00.

Test with the following income data:

163,300.00

9,876.01

85,525.00

In: Computer Science

Describe and analyze an algorithm to determine the number of shortest paths from a source vertex...

Describe and analyze an algorithm to determine the number of shortest paths from a source vertex s to a target vertex t in an arbitrary directed graph G with weighted edges. You may assume that all edge weights are positive and that all necessary arithmetic operations can be performed in O(1) time.

[Hint: Compute shortest path distances from s to every other vertex. Throw away all edges that cannot be part of a shortest path from s to another vertex. What’s left?]

Write a pseudo code algorithm for the situation described above. :)

In: Computer Science

How does the USA PATRIOT Act of 2001 pertain to computer forensics? What aspects of the...

  • How does the USA PATRIOT Act of 2001 pertain to computer forensics? What aspects of the field are covered in the act? In what ways is the act beneficial?
  • What does the act not address with regard to computer forensics? What loopholes do you see?
  • What parts of the act do you believe are unnecessary or overreaching concerning digital evidence?

In: Computer Science

For exam review: Given a stack S1 with n numbers and an empty stack S2, design...

For exam review:

Given a stack S1 with n numbers and an empty stack S2, design an algorithm (and write psudeocode for it) to sort all the numbers (from small on top to large on bottom) and store them in the originally empty stack S2, using only the stack ADT functions with the two given stacks, and a fixed number (independent of n) of int and char variables. What is the time complexity of your algorithm (related to n) in the BEST/WORST case?

In: Computer Science

2. Write a C++ program that; Takes in the weight of a person in Kilograms, converts...

2. Write a C++ program that;

Takes in the weight of a person in Kilograms, converts and outputs the equivalent weight in pounds. Format your output to 3 decimal places. Your output should look like this

53.000 Kg is equivalent to 123.459 Ibs

(Note 1Kg = 2.2046226218488 lbs)

Takes in the price of an item on an online store in pound sterling, converts and outputs the equivalent price in U.S dollars. Format your output to 2 decimal places.

Your output should look like this

£24.49 is equivalent to $31.96

To output the pound symbol, you need to display char(156). 156 signifies the pound notation's location on the ascii table shown in class

cout << char(156);

(Note £1 = $1.3048)

*BOTH CONVERSIONS SHOULD BE DONE IN THE SAME PROGRAM*

In: Computer Science

Which of the following is a database client software? Microsoft SQL Server 2017 Developer Microsoft SQL...

  1. Which of the following is a database client software?
  1. Microsoft SQL Server 2017 Developer
  2. Microsoft SQL Server Management Studio
  3. Microsoft SQL Server Configuration Manager
  4. SQL Server Analysis Service

  1. Compared to Data Warehousing approach, the following are disadvantages of query-driven data integration approach, EXCEPT: __________.
  1. competition with local processing at source
  2. delay in query processing
  3. waste of storage space
  4. inefficient and potentially expensive for frequent queries

  1. What does OLAP stand for?
  1. Olympic Linear Algebra Problem
  2. On-Line Amazon Platform
  3. On-Line Analytical Processing
  4. One Lazy Associate Professor
  1. In order to login to a non-local database server (i.e., use computer A to login to database hosted on computer B), what information is NOT required?
  1. username
  2. password
  3. IP address of the database server
  4. Number of tables in the database

  1. Which of the following is a WRONG statement?
  1. If you stop your t3-medium EC2 instance whenever you don’t use it, you can save money.
  2. If you terminate your EC 2 instance, everything inside your instance is also deleted.
  3. If you stop your EC2 instance during installation of some software, the installation will fail.
  4. If you close your remote desktop connection (or SSH) to EC2 instance, any ongoing process (e.g., installing software, running SQL queries) inside EC2 is interrupted.

  1. Which of the following database roles has the highest privileges?
  1. db_datareader
  2. db_datawriter
  3. db_securityadmin
  4. db_owner

  1. The attribute "Price" in the Sensor table is a/an _________ attribute.
  1. int
  2. float
  3. varchar
  4. datetime

In: Computer Science

describe each lines for each functions #include <stdio.h> /*Method to find the length of String*/ int...

describe each lines for each functions

#include <stdio.h>

/*Method to find the length of String*/
int str_len(char str[])
{
int i=0;
int stringLength=0;
while(str[i]!='\0')
{
stringLength+=1;
i++;
}
return stringLength;
}

/*Method to reverse string in iterative manner*/
void simpleReverse(char* str)
{
int stringLength=str_len(str);
  
for(int i=0;i<stringLength/2;i++)
{
char temp=str[i];
str[i]=str[stringLength-i-1];
str[stringLength-i-1]=temp;
}
}

/*Method to reverse string in iterative manner*/
void recursiveReverse(char str[], int start, int end)
{
if( start < end )
{
//swap
char temp = str[start];
str[start] = str[end];
str[end] = temp;
recursiveReverse(str, ++start, --end);
}
}

/*Method to print string*/
void printString(char str[])
{
int i=0;
while(str[i]!='\0')
{
printf("%c",str[i]);
i++;
}
printf("\n");
}

int main()
{
/*
Part 1: Storing a String
*/
char buffer1[]={'t','h','i','s',' ','i','s',' ','t','h','e',' ','f','i','r','s','t',' ','b','u','f','f','e','r','\0'};
char buffer2[]={'t','h','i','s',' ','i','s',' ','t','h','e',' ','s','e','c','o','n','d',' ','b','u','f','f','e','r','\0'};
char buffer3[80];
/*User Input to string using scanf() and format specifier:%s*
scanf("%s",&buffer3) only accepts string till first space is encountered space
scanf(" %[^ ]s",&buffer3) for string with space
*/
scanf("%s",&buffer3); /**/
  
  
/*Part 2: assigning pointer to array*/
char *pBuffer=buffer3;
printString(buffer3);
  
/*Part 3*/
/*Buffer 3 before reversing*/
printf("String before reversing: \n");
printString(buffer3);
/*Reversing buffer3 using simpleReverse():Iterative Method*/
simpleReverse(buffer3);
/*Data of string is changed in memory.*/
printf(" String After Reversing \n");
/*Buffer 3 after reversing*/
printString(buffer3);
  
  
printf(" String Reverse Using Recursion: \n");
  
/*Reversing buffer2 using recursive approach*/
printf(" String before reversing: \n");
printString(buffer2);
/*Reversing String */
recursiveReverse(buffer2,0,str_len(buffer2)-1);
/*Data of string is changed in memory.*/
printf(" String after Reverse: \n");
printString(buffer2);
  

return 0;
}

In: Computer Science

In Rars RIsc V Write a program that lets you enter a string. Maximum length 50.Then,...

In Rars RIsc V

Write a program that lets you enter a string.

Maximum length 50.Then, perform the sorting algorithm sort it in regards of the ascii values.

Print the string BEFORE and AFTER the sort in separate rows.

In: Computer Science

3. Write a C++ program that takes in the name of a store, and the following...

3. Write a C++ program that takes in the name of a store, and the following details for 4 employees working at the store; their first name, last name, number of hours they worked that week and how much they are paid per hour. Your program should output the name of the store, along with each employee's full name and how much they earned that week in the manner below. Monetary values should be format to 2 decimal places. Also consider that a store could have as many words contained in it's name (Best Buy, Harris Tetter, The Home Depot)

Ballack's Electronic Store

Jon Snowden $452.50

Midoriya Izuku    $363.99

Thomas Muller $1322.00

Senku Ishigami $895.50

Use the different output formatting methods

In: Computer Science