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
Natali5045456 [20]
3 years ago
12

Write a program that asks the user to enter a series of single digit numbers with nothing separating them. Read the input as a C

-string or a string object. The program should display the sum of all the single-digit numbers in the string. For example, if the user enters 2514, the program should display 12, which is the sum of 2, 5, 1, and 4. The program should also display the highest and lowest digits in the string.
Computers and Technology
1 answer:
vladimir2022 [97]3 years ago
4 0

Answer:

#include <stdio.h>

#include <string.h>

int main(){

   char number[100];

   printf("Number: ");

   scanf("%s", number);

   int sum = 0;

   for(int i =0;i<strlen(number);i++){

       sum+= number[i] - '0';

   }

           printf("Sum: %d",sum);

   return 0;

}

Explanation:

This declares a c string of 100 characters

   char number[100];

This prompts user for input

   printf("Number: ");

This gets user input

   scanf("%s", number);

This initializes sum to 0

   int sum = 0;

This iterates through the input string

   for(int i =0;i<strlen(number);i++){

This adds individual digits

       sum+= number[i] - '0';

   }

This prints the calculated sum

           printf("Sum: %d",sum);

   return 0;

You might be interested in
What is the syntax of sinX????
kkurt [141]
The syntax of sinX is the script used in sinX. 
The syntax of something, whether it be Python, C++ or even sinX is just the code. 
That's why when you check the code for errors, the button says "check syntax"!
3 0
3 years ago
Unicode is a world standard to represent _________________
horsena [70]

Answer:

characters.

Explanation:

We need to represent characters in binary format so that they can be stored in computer memory. Earlier, ASCII (American Standard Code for Information Interchange) representation was commonly used for english characters. But ASCII was found to be insufficient for representing multilingual and special characters.Unicode character representation was developed to overcome this limitation.

8 0
3 years ago
Which of the following is probably not a place where it is legal to download the music of a popular artist whose CDs are sold in
nignag [31]

Answer:

A. Personal blogs

Explanation:

I did the quick check, and there you go...it's A.

5 0
3 years ago
Write a javascript program that reads three integers named start, end, and divisor from three textfields. your program must outp
Karolina [17]
Please take down this question.  It is a test question and posting it on this forum is considered cheating.
7 0
3 years ago
Read 2 more answers
What computing and payment model does cloud computing follow?
IgorLugansk [536]

a: Rent

b. The pay as you go

Pay as you go is a utitlity computing billing method used for cloud computing and gear towards organizations and end users.

3 0
3 years ago
Other questions:
  • Numbering exception conditions, which often uses hierarchical numbering, in a fully developed use case description is helpful to
    7·1 answer
  • Which of the following are you likely to find between multiple school buildings in a city wide school district?
    9·1 answer
  • •What are some conflicts between humans and machines that have arisen in the past?
    14·1 answer
  • To what extent can u justify that computer is not the only ICT tool?​
    9·1 answer
  • What content is important to include in your webpage?
    9·1 answer
  • Explain the need for data structures when developing software.
    12·1 answer
  • ___________________ are aggregated collections of memory and cpu resources that can be shared among groups of virtual machines o
    11·1 answer
  • The process of giving the user the result of processing is called
    14·1 answer
  • Brain of the computer system is called​
    15·2 answers
  • Group of programs are software <br>​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!