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
Mrs. Schlair has an annual salary of $96,402.<br> a. What would her semimonthly salary be?
amid [387]

Answer:$4016.75

Explanation:64333/24

3 0
3 years ago
True or false? A medical assistant can check for available exam rooms and providers using an electronic scheduling system.
lutik1710 [3]
This is true m8 hope this helps
4 0
3 years ago
Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.
Marina86 [1]

Answer:

Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.

Explanation:

Artificial intelligence (AI) is a wide-ranging tool that enables people to rethink how we integrate information, analyze data, and use the resulting insights to improve decision making—and already it is transforming every walk of life. In this report, Darrell West and John Allen discuss AI's application across a variety of sectors, address issues in its development, and offer recommendations for getting the most out of AI while still protecting important human values.

4 0
3 years ago
Read 2 more answers
A(n) ______of the audio or video clip makes the content easily accessible to people with hearing disabilities.
defon

subtitles

hope that helped you

7 0
4 years ago
Read 2 more answers
Databases that carry their data in the form of tables and represent relationships using foreign keys are called _____ databases.
Butoxors [25]
Relational databases.
7 0
4 years ago
Other questions:
  • Two electronics students are discussing static electricity and electric current. Student A says that a basic property of static
    12·1 answer
  • a problem exists when the current condition differs from a desired condition. This idea defines which step in problem-solving?
    13·2 answers
  • Required
    12·1 answer
  • What is the difference between a software package and integrated software
    7·1 answer
  • What are the nicknames for the first generation computers
    8·1 answer
  • What advantage does digital storytelling have over oral storytelling traditions?
    6·1 answer
  • Consider an unpipelined or single-stage processor design like the one discussed in slide 6 of lecture 17. At the start of a cycl
    10·1 answer
  • A 'array palindrome' is an array which, when its elements are reversed, remains the same (i.e., the elements of the array are sa
    13·1 answer
  • Suppose we want an error correcting code that will allow all single-bit errors to be corrected for memory words of length 15. 1.
    5·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of cust
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!