Reference no: EM131049682
Programming Assignment
Topics: Arrays in C.
For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it.
Requirements:
- Your program must compile and run correctly using the gcc compiler on ale.
- You must write the corresponding function definitions for the following function prototypes:
// set all elements of the histogram to zero
void init_histogram(int histo[]);
// construct the histogram from string
void cons_histogram(char string[], int histo[]);
// display the histogram to the screen in a "nice" format
void display_histogram(int histo[]);
- Your functions must work with the following program:
#include <stdlib.h>
#include <stdio.h>
#define MAX_CHAR 255 // largest ASCII(Extended) value for characters
typedef unsigned char byte; // may be useful for casting(s)
void init_histogram(int histo[]);
void cons_histogram(char string[], int histo[]);
void display_histogram(int histo[]);
int main(int args, char *argv[])
{
int histo[256];
if (args == 2)
{
init_histogram(histo);
cons_histogram(argv[1], histo);
display_histogram(histo);
}
else
exit(1);
return 0;
}
void init_histogram(int histo[])
{
// your code here
}
void cons_histogram(char string[], int histo[])
{
// your code here
}
void display_histogram(int histo[])
{
// your code here
}
Outline:
- Create / open a .c file using pico, in your UNIX account
1. Write the necessary C statementss to meet the game specification given above
- Make sure to test your "program" when it is done
2. You really need to run your program a number of time to do this thoroughly
Notes(s):
- Only those characters that occurred at least once are reported.
- The minimal occurrence may very well not be unique.
- The value of a char variable is an integer value and hence can be used as an index into the histogram - once casted as unsigned to be safe.
Sample Run(s):
% ./a.out hgfjkddjkrui3
3 appeared 1 time
d appeared 2 times
f appeared 1 time
g appeared 1 time
h appeared 1 time
i appeared 1 time
j appeared 2 times
k appeared 2 times
r appeared 1 time
u appeared 1 time
Create a notes and handouts header and footer
: You are a student employee of your college's Student Success department. A previous employee created a presentation for students to view while they are waiting for their advisor.
|
Value of investment incorporating the tax shields
: The WACC, APV and FTE methods determine the value of an investment incorporating the tax shields associated with leverage. However, some other potential imperfections are associated with leverage: Security mispricing, Financial distress and agency co..
|
How much must he set aside annually from until retirement
: Arthur Anderson wants to retire in 15 years, and would like to put aside enough to give himself an income of $25,000 per year for 25 years after retirement. If he an earn 10% compounded annually over the whole time span and save and equal amount each..
|
When using the bond-yield-plus-risk-premium method
: Root Stock Inc. is estimating its WACC. Its target capital structure is 20 percent debt, 20 percent preferred stock, and 60 percent common equity. Its bonds have a 12 percent coupon, paid semiannually, a current maturity of 20 years, and sell for $90..
|
Write a c program that uses its first command line
: For this assignment, you will write a C program that uses its first command line parameter to compute and display a histogram of characters that occur in it.
|
Considering leasing arrangement-straight-line basis
: Redstone Corporation is considering a leasing arrangement to finance some special manufacturing tools that it needs for production during the next three years. A planned change in the firm's production technology will make the tools obsolete after 3 ..
|
Interest per month on the unpaid balance
: If you buy a computer directly from the manufacturer for $3,050 and agree to repay in 36 equal installments at 1.72% interest per month on the unpaid balance, How much are your monthly payments?
|
Determining the mobile communication technique
: In a congested city which of the following mobile communication technique would you use?
|
E-loan an online lending service
: E-Loan, an online lending service, recently offered 36 month auto loans at 3.6% to applicants with good credit ratings. If you have a good credit rating and can afford monthly payments of $347, how much can you borrow from A-loan? What is the total i..
|