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]
2 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]2 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
A customer survey asked respondents to indicate their highest levels of education. The only three choices in the survey were hig
solong [7]

Answer:

27%

Explanation:

100% = 26% + 47% + x%

100% = 73% + x%

27% = x%

4 0
2 years ago
g Assume that this program is run on a processor with data cache of size big enough that the entire array arr can fit in the cac
Dimas [21]

Answer:

A. 2

Explanation:

The food function in the C source code uses two for loop statements to fill and array of size 100 with 100 values ranging from 1 to 100 and the second to get the total sum to the values in the array. With this, two program paths are created.

7 0
2 years ago
The Next Einstein Initiative and the ________ Institute for Mathematical Sciences bring bright young learners and the best lectu
Degger [83]

Answer:

The correct answer is B. Africa

Explanation:

African Institute for Mathematical Sciences (AIMS) was founded in 2003 having its first center in Cape Town, South Africa. AIMS provides training for Africa's talented university graduates needed to enter technical professions or pursue graduate studies in technical fields. The Next Einstein Initiative (NEI) is a strategic plan to build on the success of the first AIMS centre and create a coordinated pan-African network of 15 AIMS centres by 2020, producing 750 well-qualified graduates per annum. AIMS won the Google's Project 10^100 and also the founder of AIMS won the TED Prize and announced his vision to unlock scientific talent across Africa.

5 0
3 years ago
You give an object a more meaningful name by setting the object’s _________________ property.
viva [34]

Answer:

The correct answer to this question is "Name".

Explanation:

In the programming language, the object is a part of the object-oriented programming language (oops).In all (oops) programming language we use class and object. where class is a collection of data member and member function, and object is a real-world entity. An Object is an instance of a Class. When a class is created, no memory is assigned but when we create the object of the class then memory is allocated.

In this question except option (d), all options are wrong.

7 0
2 years ago
What is the full form of w3c
Xelga [282]
The World Wide Web Consortium, which <span>is an international community where organizations, employees</span><span> and the general public work together to develop Web standards.</span>
7 0
2 years ago
Other questions:
  • Sean is white hat hacker, who is demonstrating a network level session hijack attacks and as part of it, he has injected malicio
    6·1 answer
  • Ryan is looking at investment opportunities as a cloud service provider. He wants to invest in a deployment-based cloud model th
    11·2 answers
  • Which command on the Insert tab of the PowerPoint Online application is used to add a Venn diagram or process chart to a present
    12·2 answers
  • Your ___ can provide hardware firewall protection for your home network where it connects to the ISP's network, just as ISP netw
    12·1 answer
  • Durante 10s, la velocidad de rotación y el momento de giro de las ruedas de un coche eléctrico son 100 rpm y 1405,92 Nm, respect
    13·1 answer
  • To use   ( 2 complement ) answer it (101101)2 – (1100)2 =   (                    )2
    12·1 answer
  • Jiwoo is a professional photographer. Identify and describe a photography scenario where Jiwoo would need to consider the ethics
    12·1 answer
  • Lily obtained data from five trails 50 kcal 72 kcal 12 kcal and 50 kcal which best decribes her data
    11·1 answer
  • Can anyone please help me out
    10·1 answer
  • What is a for command? can u use a variable instead of a number in the for command!<br>​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!