Write a c program that uses its first command line

Assignment Help Basic Computer Science
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

Reference no: EM131049682

Questions Cloud

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..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  The gorilla robot wants to play

The Gorilla Robot Wants to Play

  Describe rapid adoption of software as a service

The popularity and rapid adoption of Software as a Service (SaaS), Platform as a Service (PaaS), and Infrastructure as a Service (IaaS) by a number of organizations has impacted internal IT / IS departments.

  In an overview, describe the multics operating system

In an overview, describe the Multics operating system project which was under taken at MIT in the 1960's. Identify any impacts and influences Multics has had on modern day trends in developing secure and trusted software.

  Which ones are equivalent

Are there any states that could be collapsed withoutchanging the result of any game? If so, which ones are equivalent?

  What other properties might be useful for network addresses

One property of addresses is that they are unique; if two nodes had the same address it would be impossible to distinguish between them.

  Describe a group project for which videoconferencing

Describe a group project for which videoconferencing would be a necessity. What options are available for video conferencing.

  Use a cluster to provide fault-tolerant computing

Describe the trade-offs between your solution and a single multiprocessor-based computer system solution.

  Program with ascii version of the classic game

This question is about working with 2 dimensional arrays. In this program, you will implement an ascii version of the classic game "Connect 4".

  Central role of it in the contemporary business organization

Understand the central role of IT in the contemporary business organization. Understand the impact of the World Wide Web on the management of business

  Dss projects

DSS projects succeed more often than they fail or are challenged.

  Contact at least three people at your school or a nearby

1. contact at least three people at your school or a nearby company who use informationnbspsystems. list the systems

  Describe how the deadlocks can be resolved

give at least two real life examples ( not related to a computer system invironment) of each of these concepts:deadlock, starvation, and race. describe how the deadlocks can be resolved.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd