1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nadusha1986 [10]
3 years ago
11

Write a program "addnumbers.c" where it takes as many arguments as the user includes as command line arguments and calculates th

e sum of all numbers entered, and prints it. You will find using function atoi() from stdlib.h library helpful, where it converts the string representation of an integral number to an int value. Compile it on a lab machine and run it using command line.

Computers and Technology
1 answer:
gogolik [260]3 years ago
8 0

Answer:

#include <stdio.h>

#include <stdlib.h>

int main(int argc, char* argv[])

{

int first, second, total;

if (argc < 2)//checking if there are enough arguments

{

 printf("not enough values\n");

 return -1;//terminate program

}

total = 0;

for (int i = 1; i < argc; i++)

{

 //atoi convert a string into int. doing this to use operator

 total = total + atoi(argv[i]);//add current total to next argumment

}

printf("final total sum: %d\n", total);//printing final total

return 0;

}

Explanation:

For command line arguments you have to use command prompt. It varies depending on you machine and where you code is placed.

So, go to command line, called "command prompt" on Windows. This should open the black screen, also called the Terminal. A picture is attached in the answer. Then you have to NAVIGATE to the directory of your program. So, let's say your code is on your desktop. You will have to navigate to your desktop. To do this, type:

"cd Desktop", and press enter.

The picture of my process is attached below too.

Then, the program we have made is called addnumbers. we will type,

"addnumbers 10 20 30 40 50"

add numbers is the name of the program followed by arguments, separated with spaces.

You might be interested in
Kelly is a college sophomore majoring in computer science. She is interested in gaining exposure to the most useful and current
Nuetrik [128]

Answer:

Java

Explanation:

Java is a general-purpose programming language that is object-oriented, and has strong support for web development.

Therefore, one of the languages that a college sophomore majoring computer science learn is <u>Java,</u> an object-oriented programming language that is commonly used to write Web applications.

6 0
3 years ago
How to transfer photos from iphone to computer
SSSSS [86.1K]
If you’re using a Windows computer, the best way to transfer photos from your iPhone to your computer is via USB cable.
First, plug your phone into your computer using the phone’s USB Cable. The Photo app should launch automatically then click the Import button. Check to select the photos you wish to transfer. Once you checked all the photos you wish to transfer, click on Continue. Click Import to start the transfer.
3 0
3 years ago
Robots can work 24 hours a day, 365 days of the year, but human beings
statuscvo [17]

The word that best completes the sentence is:  "<em>can't</em>".
6 0
3 years ago
Read 2 more answers
Intellectual property rights are exclusive rights that help protect both the created and the creation. IPR offers exclusively wh
dedylja [7]
IPR offers ownership of the intellectual property. The owner of the property has the right to a monetary gain from those who wish to use it.
8 0
2 years ago
Read 2 more answers
Anil needs to show the overlap of people who live in a certain neighborhood in his city and who support a specific political can
pantera1 [17]

Since Anil needs to show the overlap of people who live in a certain neighborhood in his city that supports a specific political candidate, the type of conceptual diagram which he should use is a: B: Venn diagram.

<h3>What is a Venn diagram?</h3>

A Venn diagram can be defined as a circular graphical (visual) tool that is typically used for representing, logically comparing and contrasting two (2) or more finite sets of data such as objects, students, events, voters, concepts, people, etc.

In this context, we can reasonably infer and logically deduce that a Venn diagram is a type of conceptual diagram which can be used by Anil in illustrating the overlap of people who are living in a certain neighborhood in his city and supports a specific political candidate in an election.

Read more on Venn diagram here: brainly.com/question/24581814

#SPJ1

8 0
11 months ago
Other questions:
  • When creating an input control (for example, a button) on a form the _____________ indicates the data that is contained in the n
    13·1 answer
  • It is important that data being imported from a text file into access are separated by a character, such as a comma, which defin
    8·1 answer
  • Which of the following identifies the patterns used for each data series in a chart?
    13·1 answer
  • Read the scenario below and then answer the
    14·1 answer
  • I'm 11, except my profile says I'm 15.
    15·1 answer
  • Convert 78 to binary
    6·2 answers
  • A browser is used for creating Web pages. true or false?
    5·2 answers
  • Danica is creating a flyer for her cookies that she will sell during her school fair. She wants to add a registered
    7·1 answer
  • What legal protection would cover a person invention?
    10·2 answers
  • How do you enlarge an image to see more detail on it? (1 point)
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!