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
it just said i was blocked from brainly for a sec i was like- dang- then i logged in again then it was back to normal uHhHh can
PSYCHO15rus [73]

Answer:

it has been doing the same to me if your on a school computer at home then it will bug sometimes but if you were at school then it would probably be entirely blocked but idrk

Explanation:

5 0
2 years ago
Read 2 more answers
Difference between ancient and modern mode of information <br> transmission
ELEN [110]
Ancient mode of transmission are used by people in the past while modern mode of transmission are used by present people
4 0
3 years ago
Which are the best examples of costs that should be considered when creating a project budget?
Vlada [557]

Answer:

I would say material costs and hiring costs, idk if that helps or not

4 0
3 years ago
How do I go to files in Brainly I need help
Lyrx [107]

Answer:

There should be a little icon at the bottom of your question box/answer box. It looks like a paper clip. click it and boom

Explanation:

4 0
3 years ago
9- Write a program in MARIE to add three numbers.
Korvikt [17]

A series of instructions written in a programming language for a computer to follow is referred to as a computer program.

<h3>What is program?</h3>

Software, which also contains documentation and other intangible components, comprises computer programs as one of its components.

The source code of a computer program is the version that can be read by humans. Since computers can only run their native machine instructions, source code needs to be run by another software.

Using the language's compiler, source code may be converted to machine instructions. (An assembler is used to translate programs written in machine language.) An executable is the name of the generated file.

Therefore, A series of instructions written in a programming language for a computer to follow is referred to as a computer program.

To learn more about program, refer to the link:

brainly.com/question/11023419

#SPJ1

8 0
10 months ago
Other questions:
  • Sniffing network and wireless traffic, intercepting bluetooth traffic, and even using equipment to remotely pull information fro
    12·1 answer
  • How can investors receive compounding returns
    13·1 answer
  • Blank includes websites that encourage interaction and connection among people ,business and organizations
    13·1 answer
  • Tammy is preparing to give a presentation. she would like to view information that will remind her what to say to her audience b
    10·1 answer
  • Part cost Calculator Modify the GUI in your program to look like the following GUI. To do that you need to add the following to
    13·1 answer
  • Two technicians are discussing a resistance measurement. Technician A states that components being measured should be removed or
    10·1 answer
  • _____ _____ deals with the definitions properties of mathematical models of computation.
    8·1 answer
  • Vector testGrades contains NUM_VALS test scores. Write a for loop that sets sumExtra to the total extra credit received. Full cr
    7·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    5·1 answer
  • Ranboo back story? (not homework i just wanna find some ppl who are interested in the same things) ft. the reddie meme
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!