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
A network administrator needs 10 prevent users from accessing the accounting department records. All users are connected to the
mojhsa [17]

Answer:

C

Explanation:

6 0
3 years ago
Read 2 more answers
In a relational database, the three basic operations used to develop useful sets of data are:
lesya692 [45]
<span>Which is not a component of a database that describes how data is stored?</span>
6 0
3 years ago
domain controllers store local user accounts within a sam database and domain user accounts within active directory. true or fal
Natalka [10]

Answer:

True

Explanation:

The domain controller is a server that responds within windows server domains to request for security authentication. It enforces security for windows and they are useful for storing the account information of users, that is local users within a Security Account Manager. Therefore the answer to this question is true.

Thank you!

5 0
2 years ago
Hy <br> Anyone from kerala?
Lera25 [3.4K]

Answer:

i dont know

Explanation:

7 0
2 years ago
Read 2 more answers
Write a SELECT statement that displays each product purchased, the category of the product, the number of each product purchased
Blababa [14]

Answer:

y6ou dont have mind

Explanation:

6 0
3 years ago
Other questions:
  • To gain one pound of fat, how many extra calories would you need to consume?
    12·1 answer
  • A _____________ is a method of controlled entry into a facility and provides access to secure areas such as a research lab or da
    10·1 answer
  • Which statement about trees is false?
    12·1 answer
  • A high-angle shot is the same thing as a bird’s-eye shot. True False
    11·2 answers
  • Which sign or symbol will you use to lock cells for absolute cell reference
    5·1 answer
  • Before inserting a preformatted table of contents, what must you do first?
    8·1 answer
  • A computer consists of both software and hardware. a)Define the term software​
    5·1 answer
  • How does a film establish the setting?
    14·1 answer
  • Make a list of five primary raw materials, for each one, indicate and industrial material that is created from it
    10·2 answers
  • Help plz,l didn’t pay attention in class
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!