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
Which of the following activities are performed by computer programmers? Choose all that apply.
AleksAgata [21]

Answer:

- They write step by step instructions for a computer to follow.

- They create a logic problem that the computer program can solve.

3 0
3 years ago
Why were Redditors interested in "Mister Splashy Pants"?
olganol [36]

Answer:

a

Explanation:

3 0
2 years ago
Read 2 more answers
_______________________ covers unsolicited commercial e-mail messages and requires commercial e-mail senders to meet certain req
kondaur [170]

Answer:

CAN-SPAM

Explanation:

The CAN-SPAM act covers uninvited commercial e-mail messages and requires commercial e-mail senders to meet some requirements.This act was signed by president of united states of that time George Washington Bush in 2003.

So we can say that the answer to this question is CAN-SPAM.

7 0
3 years ago
The _____ button is located on the Title bar of the word window ( start/ office)​
andrey2020 [161]
I think it is the office button sorry if not
7 0
3 years ago
Realizar una lista con 200 valores aleatorios entre 140 y 200 en Matplotlib. Graficar la distribución de los datos en un
Airida [17]

hola no conozco el toldo, pero necesito puntos cerebrales tan lo siento

Explanation:

7 0
3 years ago
Other questions:
  • .exe, .msi, .msp, .inf - together, what do these filetypes indicate
    12·2 answers
  • Which line in the following program contains the header for the showDub function? 1 #include«iostream» 2 using namespace std; 4
    15·1 answer
  • What tool can help discover and report computer errors and conflicts that occur when you first turn on a computer and before the
    15·1 answer
  • Write a programme with C++ language wich print the biggest number in between three numbers , whith INT
    14·1 answer
  • Seeing an error message on the screen after you click on a link or icon may indicate that your PC doesn't have the correct _____
    15·1 answer
  • The name of a .java file should ______________________________. Always match the name of the Class inside Should always start wi
    9·1 answer
  • Which is the correct expansion of the term Internet?
    15·2 answers
  • Complete the steps for adding a recurring event.
    10·1 answer
  • En una Memoria SD de 128 Gb, ¿Cuántas fotos en alta resolución de 16 Mb puedo almacenar?
    12·1 answer
  • What is the output for the following program?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!