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
Given the following code fragment and the input value of 4.0, what output is generated?
kicyunya [14]

Answer:

c) 4.4

Explanation:

You can evaluate step by step the code. You know tha your input is 4.0

Step 1 Variables definitions:

double tax;

double total;

Step 2 Ask the user for the input:

System.out.print("Enter the cost of the item");

Step 3 read de input:

total = scan.nextDouble();

Step 4 evaluate the condition (  is the input greater or equal  than 3.0 ? [True])

if ( total >= 3.0)

Step 5 get done the operations inside the condition and print it:

tax = 0.10;

System.out.println(total + (total * tax));

4 0
3 years ago
Someone help me please
MA_775_DIABLO [31]

Answer:

I think it is the last 2 but i am not 100% sure.

Explanation:

3 0
3 years ago
О OF<br>Types icts commonly<br>in education.<br>used​
Kipish [7]

Answer:

The types of the itcs can be defined as follows:

Explanation:

It stands for the information and communication technology, which is used to comprises products that are a store, process, pass, transform, replicate or receive digital communications. 

It applies to all technology of interaction, such as the Internet, wireless networks, devices, laptops, middleware, video - conferencing, social media, and other software and services in media, and the four types in which it is used in education can be defined as follows:

(i) networking for education

(ii) Web-based education

(iii) mobile education

(iv) facilities for the classroom

8 0
3 years ago
The processing is done in the​
Lady_Fox [76]

Answer:

CPU Central Processing Unit

5 0
3 years ago
Read 2 more answers
A user wants to visualize a highly complex 3-D model using a virtual reality headset. What is the best way for the user to do th
Ilya [14]

Explanation:

3D printing Use

Able to print or bones just as a heart or a rib cage. Is especially ideal as Doctors can use patients own cells so organ or bone is an exact match. This saves patients from being on waiting lists. Also able to print car parts, rocket engines for NASA, and prosthetic limbs.

Ex: Greys Anatomy

6 0
2 years ago
Other questions:
  • Explain Cascading Style Sheets and what they do. Describe their primary function, two effects that this function has on programm
    11·1 answer
  • When you arrive at work one morning, your inbox is full of messages complaining of a network slowdown. you collect a capture fro
    12·1 answer
  • There are three types of value for money. Which of the following is not a method of value?
    14·1 answer
  • Write a JavaScript program to generate the following pattern but the number of rows should be user input.
    8·1 answer
  • Why computer process faster than humans?​
    10·2 answers
  • has anyone noticed to get credit for answering a question you don't even need to answer it correctly?
    11·2 answers
  • Which programming language uses objects?<br> O C++<br> O ALGOL<br> O Pascal<br> O BASIC
    14·2 answers
  • What layer in the Transmission Control Protocol/Internet Protocol (TCP/IP) model is responsible for defining a way to interpret
    11·1 answer
  • Which of the following occurs during data cleansing?
    9·1 answer
  • Please Help! <br> I need good Anime to watch!
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!