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

  What is the :: called in c++

What is the :: called in C++ when used like this std::endl; In my main file, what line of code prevents me from having to put std before every endl

  The game of life

The game of Life, invented by the mathematician John H. Conway, is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism

  Prompts the user to enter the total amount of milk produced

Prompts the user to enter the total amount of milk produced in the morning. Outputs the number of milk cartons needed to hold milk. Outputs the cost of producing milk.

  Write a program that will find the smallest number

How to do the subsequent program WITHOUT USING Arrays - Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value N before scanning each value in the collection of N numbers.

  Create code using raptor flowchart programming

Demonstrate your analytical and problem-solving skills in analyzing a problem statement and providing your solution by developing a Raptor program that addresse

  Display a list of items and the location in the store

The program should display a list of items and the location in the store. The user must be able to enter the items and location in the store. You will use a class for the items. For this assignment you will implement creating the list, adding eleme..

  Grade book program for his class

Your English instructor, realizing you are a programmer, asks you to write a Grade Book program for his class to help him compute final grades. Design a program that asks for the student's name and four test grades.

  Write a program manipulating a 2-dimensional array

Write a program manipulating a 2-dimensional array. Create constants to represent your number of students and number of assignments.

  An integer on this system is 4 bytes long

Assume the following for the program below. An integer on this system is 4 bytes long. The memory address where the array "a[]" was created begins at location 8000. a. #include

  Identify two key oo concepts and explain them as if you

1. discuss the advantages and disadvantages of both the structured and object-oriented oo paradigm in programming. why

  Create example c++ code based on working logical flow chart

Use the generate dropdown to create example C++ code based on your working logical flow chart. Also attached the code in a Microsoft Word file or a text file

  C++ program that takes temperature as input

Create a C++ program that takes temperature as input and provides as output your sports decision. Assume that temperatures are only expressed as integers. In the program, include 2 void functions titled getTemp and printActivity, each with an int ..

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