Write a C program that repeatedly prompts the user for input at a simple prompt (see the sample output below for details). Your program should parse the input and provide output that describes the input specified. To best explain, here's some sample output:
ibrahim@ibrahim-latech:~$ ./prog1
$ ls -a -l -h
Line read: ls -a -l -h
Token(s):
ls
-a
-l
-h
4 token(s) read
$ ls -alh
Line read: ls -alh
Token(s):
ls
-a
-l
-h
2 token(s) read
$ clear
Line read: clear
Token(s):
clear
1 token(s) read
$ exit ibrahim@ibrahim-latech:~$
Note that the first and last lines are not part of program output (i.e., they are of the terminal session launching the program and after its exit). The program prompts the user (with a simple prompt containing just a $ followed by a space) and accepts user input until the command exit is provided, at which point it exits the program and returns to the terminal. For all other user input, it first outputs the string Line read: followed by the user input provided (on the same line). On the next line, it outputs the string Token(s):. This is followed by a list of the tokens in the input provided, each placed on a separate line and indented by a single space. For our purposes, a token is any string in the user input that is delimited by a space (i.e., basically a word). The string n token(s) read is then outputted on the next line (of course, n is replaced with the actual number of tokens read). Finally, a blank line is outputted before prompting for user input again. The process repeats until the command exit is provided. Hints: (1) An array of 256 characters for the user input should suffice (2) To get user input, fgets is your friend (3) To compare user input, strcmp is your friend (4) To tokenize user input, strtok is your friend Turn in your .c source file only that is compilable as follows (filename doesn't matter): gcc -o prog1 prog1.c Make sure to comment your source code appropriately, and to include a header providing your name.
In: Computer Science
How did the New York Police Department implement their new theory of policing?
In: Psychology
In C++, dealing with Binary Search trees. Implement search, insert, removeLeaf, and removeNodeWithOneChild methods in BST.h. BST.h code below
#include <iostream> #include "BSTNode.h" using namespace std; #ifndef BST_H_ #define BST_H_ class BST { public: BSTNode *root; int size; BST() { root = NULL; size = 0; } ~BST() { if (root != NULL) deepClean(root); } BSTNode *search(int key) { // complete this method } BSTNode *insert(int val) { // complete this method } bool remove(int val) { // complete this method } private: void removeLeaf(BSTNode *leaf) { // complete this method } void removeNodeWithOneChild(BSTNode *node) { // complete this method } static BSTNode *findMin(BSTNode *node) { if (NULL == node) return NULL; while (node->left != NULL) { node = node->left; } return node; } static BSTNode *findMax(BSTNode *node) { if (NULL == node) return NULL; while (node->right != NULL) { node = node->right; } return node; } void print(BSTNode *node) { if (NULL != node) { node->toString(); cout << " "; print(node->left); print(node->right); } } static int getHeight(BSTNode *node) { if (node == NULL) return 0; else return 1 + max(getHeight(node->left), getHeight(node->right)); } static void deepClean(BSTNode *node) { if (node->left != NULL) deepClean(node->left); if (node->right != NULL) deepClean(node->right); delete node; } public: int getTreeHeight() { return getHeight(root); } void print() { print(root); } int getSize() { return size; } }; #endif
This is the expected output
****************** Test BST Correctness ******************
Inserting the following numbers: [11, 12, 15, 17, 12, 19, 4, 5, 11,
19, 20, 32, 77, 65, 66, 88, 99, 10, 8, 19,
15, 66, 11, 19]
*** BST Structure (after insertion) ***
<11, null> <4, 11> <5, 4> <10, 5> <8,
10> <12, 11> <15, 12> <17, 15> <19, 17>
<20, 19> <32, 20> <77,
32> <65, 77> <66, 65> <88, 77> <99,
88>
Size of BST: 16
*** Searching BST ***
Found: [19, 12, 4, 5, 19, 20, 32, 99, 8, 12]
Did not find: [29, 3, 27, 34, 45, 37, 25, 25, 24, 16]
*** Deleting BST ***
Deleted: [12, 15, 5, 17, 19, 4, 20, 32, 99, 10, 8]
Did not find: [16, 5, 19, 17, 19, 39, 19, 15, 21]
*** BST Structure (after deletion) ***
<11, null> <77, 11> <65, 77> <66, 65>
<88, 77>
Size of BST: 5
****************** Clean up ******************
Size of hash table: 0
Size of BST: 0
In: Computer Science
You are a clinical psychologist researching the field of cognitive coping mechanisms, (no use of pharmacological drugs), associated with resiliency for middle childhood children. What would you do to help cognitive coping of middle childhood children with the hopes that they can develop increased resiliency?
In: Psychology
Suppose you have the following list of integers to sort:
[1, 5, 4, 2, 18, 19]
which list represents the partially sorted list after three complete passes of insertion sort?
1 2 4 5 18 19 |
||
1 4 5 2 18 19 |
||
1 4 2 5 18 19 |
||
None of the above |
In: Computer Science
In: Psychology
The year is 1997, California Pizza Kitchen is thinking to launch a new brand of frozen pizza. You are the Brand Manager for CPK.
Your task: develop a one-page executive summary to G.J. Hart, CEO persuading him that the company should launch this product
What is CPK's key POD?
What is your recommended S-T-P?
Include a proper positioning statement (using Kotler's model) What are the company's calculated risks?
WHY should the company pursue this endeavor?
Include an introduction, and summary conclusion
In: Operations Management
What is one thing that came to mind when you read the film study or the synopsis of Iron Jawed Angels?
Name one women in History that stood out for women's rights.
Why did this woman come to mind when asked that question?
In: Operations Management
Process Control at Polaroid (A)
1. Create and interpret SPC charts – Xbar and R charts for each work shift for finger height and pod weight. (provide step by step instructions on how you came up with the XBar, R, R bar, X double bar, UCL, and LCL)
Pod Weight (grams) | |||||||
Sample Number: | |||||||
Day | Shift | 1 | 2 | 3 | 4 | 5 | 6 |
3 August | A | 2.800 | 2.799 | 2.760 | 2.802 | 2.805 | 2.803 |
B | 2.750 | 2.820 | 2.850 | 2.740 | 2.850 | 2.790 | |
C | 2.768 | 2.807 | 2.807 | 2.804 | 2.804 | 2.803 | |
4 August | A | 2.841 | 2.802 | 2.802 | 2.806 | 2.807 | 2.807 |
B | 2.801 | 2.770 | 2.833 | 2.770 | 2.840 | 2.741 | |
C | 2.778 | 2.807 | 2.804 | 2.804 | 2.803 | 2.804 | |
5 August | A | 2.760 | 2.804 | 2.804 | 2.806 | 2.805 | 2.806 |
B | 2.829 | 2.804 | 2.805 | 2.806 | 2.807 | 2.807 | |
C | 2.741 | 2.850 | 2.744 | 2.766 | 2.767 | 2.808 | |
6 August | A | 2.814 | 2.804 | 2.803 | 2.805 | 2.807 | 2.804 |
B | 2.787 | 2.802 | 2.805 | 2.804 | 2.805 | 2.804 | |
C | 2.766 | 2.805 | 2.804 | 2.802 | 2.804 | 2.806 | |
7 August | A | 2.774 | 2.801 | 2.805 | 2.805 | 2.805 | 2.804 |
B | 2.770 | 2.801 | 2.833 | 2.770 | 2.840 | 2.741 | |
C | 2.832 | 2.836 | 2.794 | 2.843 | 2.813 | 2.743 | |
10 August | A | 2.829 | 2.846 | 2.760 | 2.854 | 2.817 | 2.805 |
B | 2.850 | 2.804 | 2.805 | 2.806 | 2.807 | 2.807 | |
C | 2.803 | 2.803 | 2.773 | 2.837 | 2.808 | 2.808 | |
11 August | A | 2.815 | 2.804 | 2.803 | 2.804 | 2.803 | 2.802 |
B | 2.782 | 2.806 | 2.806 | 2.804 | 2.803 | 2.802 | |
C | 2.779 | 2.807 | 2.808 | 2.803 | 2.803 | 2.803 | |
12 August | A | 2.815 | 2.815 | 2.803 | 2.864 | 2.834 | 2.803 |
B | 2.846 | 2.854 | 2.760 | 2.829 | 2.817 | 2.805 | |
C | 2.767 | 2.804 | 2.834 | 2.803 | 2.803 | 2.803 | |
13 August | A | 2.850 | 2.804 | 2.804 | 2.804 | 2.804 | 2.804 |
B | 2.810 | 2.820 | 2.814 | 2.794 | 2.798 | 2.787 | |
C | 2.850 | 2.820 | 2.750 | 2.740 | 2.850 | 2.790 | |
14 August | A | 2.750 | 2.765 | 2.850 | 2.760 | 2.790 | 2.840 |
B | 2.830 | 2.770 | 2.848 | 2.760 | 2.750 | 2.830 | |
C | 2.740 | 2.770 | 2.833 | 2.770 | 2.840 | 2.800 | |
17 August | A | 2.753 | 2.807 | 2.805 | 2.804 | 2.802 | 2.804 |
B | 2.851 | 2.751 | 2.752 | 2.773 | 2.849 | 2.806 | |
C | 2.845 | 2.804 | 2.803 | 2.806 | 2.805 | 2.806 | |
18 August | A | 2.844 | 2.777 | 2.754 | 2.791 | 2.833 | 2.811 |
B | 2.806 | 2.839 | 2.805 | 2.804 | 2.850 | 2.740 | |
C | 2.849 | 2.801 | 2.804 | 2.762 | 2.814 | 2.791 | |
19 August | A | 2.820 | 2.793 | 2.812 | 2.833 | 2.853 | 2.812 |
B | 2.790 | 2.780 | 2.764 | 2.843 | 2.843 | 2.818 | |
C | 2.850 | 2.806 | 2.805 | 2.814 | 2.807 | 2.807 | |
20 August | A | 2.767 | 2.831 | 2.808 | 2.793 | 2.836 | 2.811 |
B | 2.833 | 2.825 | 2.793 | 2.813 | 2.823 | 2.766 | |
C | 2.824 | 2.799 | 2.790 | 2.764 | 2.817 | 2.805 | |
21 August | A | 2.778 | 2.775 | 2.799 | 2.805 | 2.833 | 2.772 |
B | 2.801 | 2.832 | 2.758 | 2.759 | 2.773 | 2.814 | |
C | 2.770 | 2.787 | 2.744 | 2.766 | 2.807 | 2.803 | |
Finger Height (mm) | |||||||
Sample Number: | |||||||
Day | Shift | 1 | 2 | 3 | 4 | 5 | 6 |
3 August | A | 1.90 | 1.95 | 1.94 | 2.00 | 2.05 | 2.16 |
B | 2.15 | 2.17 | 2.11 | 2.13 | 2.02 | 2.03 | |
C | 1.73 | 1.90 | 2.07 | 1.89 | 1.76 | 1.88 | |
4 August | A | 2.30 | 2.41 | 2.54 | 2.37 | 2.32 | 2.16 |
B | 2.28 | 2.16 | 2.19 | 2.08 | 2.25 | 2.24 | |
C | 1.92 | 2.24 | 2.11 | 1.89 | 1.88 | 2.17 | |
5 August | A | 2.39 | 2.28 | 2.10 | 2.36 | 2.54 | 2.25 |
B | 2.11 | 2.21 | 2.24 | 2.21 | 2.17 | 2.24 | |
C | 1.89 | 1.90 | 1.73 | 2.07 | 1.89 | 1.76 | |
6 August | A | 2.51 | 2.25 | 2.08 | 2.35 | 2.29 | 2.32 |
B | 2.22 | 2.19 | 2.22 | 2.24 | 2.01 | 2.23 | |
C | 1.89 | 1.90 | 1.78 | 2.07 | 1.89 | 1.76 | |
7 August | A | 1.95 | 2.07 | 2.25 | 1.95 | 2.11 | 2.16 |
B | 2.08 | 2.03 | 2.27 | 2.23 | 2.24 | 2.13 | |
C | 2.31 | 1.90 | 1.86 | 1.91 | 1.89 | 1.87 | |
10 August | A | 2.23 | 2.25 | 2.21 | 1.89 | 2.15 | 2.11 |
B | 2.23 | 2.21 | 2.05 | 2.19 | 2.07 | 2.16 | |
C | 1.73 | 2.00 | 1.79 | 1.75 | 1.84 | 1.74 | |
11 August | A | 2.21 | 2.11 | 2.21 | 2.44 | 2.17 | 2.30 |
B | 2.17 | 2.19 | 2.15 | 2.04 | 2.07 | 2.22 | |
C | 2.01 | 1.90 | 1.90 | 1.81 | 2.06 | 1.89 | |
12 August | A | 2.08 | 2.19 | 2.28 | 2.29 | 2.21 | 2.45 |
B | 1.93 | 2.09 | 1.90 | 1.95 | 2.04 | 2.09 | |
C | 1.84 | 2.12 | 1.90 | 1.89 | 2.01 | 1.75 | |
13 August | A | 2.23 | 2.01 | 2.25 | 2.11 | 2.39 | 2.15 |
B | 2.19 | 2.22 | 2.18 | 2.15 | 2.23 | 2.04 | |
C | 1.96 | 2.05 | 2.16 | 1.87 | 2.13 | 1.90 | |
14 August | A | 2.27 | 2.00 | 2.06 | 1.97 | 2.13 | 2.05 |
B | 1.92 | 1.78 | 1.76 | 1.77 | 1.78 | 1.87 | |
C | 1.78 | 1.65 | 2.04 | 1.63 | 1.75 | 1.83 | |
17 August | A | 2.31 | 2.35 | 2.25 | 1.99 | 2.27 | 2.11 |
B | 2.02 | 1.97 | 1.81 | 1.73 | 1.77 | 1.82 | |
C | 1.76 | 1.91 | 2.01 | 1.85 | 1.78 | 1.64 | |
18 August | A | 2.06 | 2.14 | 1.91 | 2.06 | 2.08 | 2.09 |
B | 1.76 | 1.83 | 1.79 | 1.79 | 1.77 | 1.94 | |
C | 2.25 | 1.88 | 2.11 | 2.18 | 2.02 | 1.86 | |
19 August | A | 2.28 | 2.15 | 2.17 | 2.18 | 2.44 | 2.00 |
B | 2.31 | 2.27 | 2.16 | 2.10 | 2.24 | 2.28 | |
C | 1.87 | 1.89 | 2.03 | 1.69 | 1.75 | 2.04 | |
20 August | A | 2.16 | 2.38 | 2.20 | 2.25 | 1.98 | 2.23 |
B | 2.06 | 2.08 | 2.14 | 2.24 | 2.26 | 2.18 | |
C | 1.80 | 1.71 | 1.65 | 1.68 | 1.96 | 2.05 | |
21 August | A | 1.75 | 2.00 | 2.04 | 2.00 | 2.15 | 2.06 |
B | 1.90 | 1.90 | 1.81 | 1.86 | 1.98 | 1.81 | |
C | 1.80 | 2.01 | 1.73 | 1.89 | 2.01 | 1.91 |
In: Operations Management
How does S/4HANAempower digital supply chain? Provide some examples on how this system is benefiting organisations to compete?
In: Computer Science
1.Define and differentiate between genetic and acquired congenital disorders. Give examples for each 2.Identify the characteristics of ADHD 3.Signs/symptoms of Fetal Alcohol Spectrum Disorders and Fetal Alcohol Syndrome. What causes it? And what is the treatment? 4.Explain Autism Spectrum Disorders: Signs/symptoms, Diagnosis, Treatment, and Nursing Considerations. 5.What does a positive Gowers’ sign mean? 6.Childhood Depression: Signs/symptoms, Diagnosis, Treatment, Nursing Considerations. 7.What are risk factors for suicide? 8.Childhood Schizophrenia: S/S, Diagnosis, Treatment, Nursing Considerations 9.What are the most commonly used drugs in adolescents? 10.What nursing consideration you would include relating to the care and upbringing of special needs children?
In: Nursing
A random sample is drawn from a normally distributed population with mean μ = 20 and standard deviation σ = 2.5. Use Table 1. |
a. |
Is the sampling distribution of the sample mean with n = 28 and n = 55 normally distributed? |
||||
|
b. |
Can you use the standard normal distribution to calculate the probability that the sample mean is less than 20.6 for both sample sizes? |
||||
|
c. |
Calculate the above probabilities for both sample sizes. (Round intermediate calculations to 4 decimal places, “z” value to 2 decimal places, and final answer to 4 decimal places.) |
n | Probability |
28 | |
55 | |
In: Math
Example 1: H2O boils at 100ºC and 1 atm. At what temperature will water boil
if pressure = 500 torr (1 atm / 760 torr) = 0.658 atm?
DvapH = 40.66 kJ mol-1.
Can you please show all steps and equations??? Thank you
In: Physics
A bee is flying down South with a velocity of 10 m/s, the wind is blowing toward the bee at a constant velocity of 3 m/s in the direction of the North-West. How far does the bee travel after 10 sec and at what direction? At what velocity should the bee fly in order to keep itself moving straight toward the South at 5 m/s?
In: Physics
Apply the different components of systems thinking on the zillow business scenario. In other words, the different components of Zillow as system, the input, the output, and the different feedbacks.
In: Computer Science