Write a program that finds either the largest or smallest

Assignment Help C/C++ Programming
Reference no: EM132076057

You need help with the following two programs.

Question 1. Write a program to remove a comment starting with /* and ending with */ in a statement, which is entered by the user. If the input does not contain a comment, the program should leave the statement as it is.

Input: int i; /*declare integer variable i*/ Output: int i; Input: int i; Out: int i;

Your program should include the following function:

void remove_comment(char *s1, char *s2);

The function expects s1 to point to a string containing the input as a string and stores the output to the string pointed by s2.

1) Name your program remove.c.

2) Assume input is no longer than 100 characters. Assume the input contains no more than one /*...*/ comment.

3) The remove_comment function should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the function.

4) To read a line of text, use the read_line function (the pointer version) in the lecture notes.

Question 2. Write a program that finds either the largest or smallest of the ten numbers as command-line arguments. With -l for largest and -s for smallest number, if the user enters an invalid option, the program should display an error message.
Example runs of the program:

./find_largest_smallest -l 5 2 92 424 53 42 8 12 23 41 output: The largest number is 424 ./find_largest_smallest -s 5 2 92 424 53 42 8 12 23 41 output: The smallest number is 2
1) Name your program numbers.c.

2) Use atoi function in <stdlib.h> to convert a string to integer form.

3) Generate the executable as find_largest_smallest.

gcc -Wall -o find_largest_smallest numbers.c

Reference no: EM132076057

Questions Cloud

Prepare a comprehensive report directed to an australian : Students are required to prepare a comprehensive report directed to an Australian ASX Top 100 listed corporation detailing a critical analysis
Internet effect on public opinion : Write a paper that summarizes how the Internet may affect public opinion in a positive or negative way with regards to brand reputation.
What does the national organ transplant act : 1. What does the National Organ Transplant Act (NOTA) regulate and what does it not regulate?
Produce a short report by investigating and advising company : This assessment item requires you to produce a short report by investigating and advising a company on some key topics and aspects of the use of virtualisation
Write a program that finds either the largest or smallest : Write a program that finds either the largest or smallest of the ten numbers as command-line arguments.
Calculate the mean access time to four decimal digits : You have a 2-level cache. Level 1 cache is 1MB and level 2 cache is 2MB. Level 1 cache has a mean access time of 20 nsec, level 2 200 nsec.
Define and explain the concept of the terminologies : Define and explain the concept of the following terminologies: Electronic Records Management; Business intelligence (BI) and Analytics;
Design and write a base e and three derived classes : Design and write a base e and three derived classes that inherit from the base (similar to the shape class and the derived shape base asses).
Write a recursive function that takes one parameter : Write a recursive function that takes one parameter n (n>0) of type int and returns

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a function int frequency

Write a function int frequency (int theArray [ ], int n, int x) that counts the number of times the item x appears among the first n elements of theArray and returns that count as the frequency of x in theArray. Use integers for everything!

  Make a full class definition for a class named counter

Make a full class definition for a class named Counter, and containing the following members:A data member counter of type int.

  What is the difference between an object and a class

What is the difference between an object and a class? What is the difference between class and structure? What are virtual functions?

  Program to compute gross wages for employee using array

Write program which uses the following arrays: payRate: array of seven floats to hold each employee's hourly pay rate. wages: array of seven floats to hold each employee's gross wages.

  Generate a series of pseudo random numbers

You will write a program to generate a series of pseudo random numbers, using a linear feedback shift register method. You will start with an arbitrary number (not zero) x with a representation in n bits.

  Imagine a tollbooth with a class called toll booth

Imagine a tollbooth with a class called toll booth. The two data items are of type unsigned int to hold the total number of cars, and a type double to hold the total amount of money collected. A constructor initializes both these to 0. A member funct..

  Discuss problem related to the pointer

The address operator (&) can be applied only to constants, to expressions and to variables declared with the storage-class register.

  Compute the sum of the first

Assume there is a variable , h already associated with a positive integer value. Write the code necessary to compute the sum of the first h perfect squares, starting with 1 .

  Objective1 to give students practice in calling and writing

objective1. to give students practice in calling and writing their own functions.2. to give students practice in

  Give a recursive definition of s.

Let S be the set of positive integers that can be written as a sum of one or more 4's and/or 7's. For example, 7 ? S and 18 ? S (because 18 = 4 + 7 + 7)

  Defiine an unsorted type adt

Postconditions: list1 contains all the items of list whose keys are less than or equal to item's key; list2 contains all the items of list whose keys are greater than item's key.

  Write c program that prompts for variable number of integers

Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out the average.

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