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
All of the following are ways to save money on transportation except :
Lisa [10]
The options listed are not related to the question. and if they were related in any sense then I would say the cheapest thing on the list is a phone card so I guess you can buy that and save the most for your travel as you can use phone cards anywhere as they have 1800 numbers which are free from any public phone. 
7 0
3 years ago
Analyze a software application that enables people to purchase prescription drugs on the internet. briefly describe this applica
stiv31 [10]
This question makes no sense
8 0
3 years ago
What is the best definition for a relationship?
velikii [3]

Answer:

special instance of a dataset

7 0
3 years ago
When using a self-contained recovery device on a cfc, hcfc, or hfc system with an operating compressor, technicians must?
Neporo4naja [7]

When using a self-contained recovery device on a cfc, hcfc, or hfc system with an operating compressor. Technicians must recover 80% of the nameplate charge.

Compressor is a mechanical device used in many industries which has the function of increasing gas pressure by reducing its volume. The air compressor is a specific type of gas compressor.

Compressors can be characterized in a number of different ways, but are usually divided into types based on the functional method used to produce compressed air or gas. The following are common compressor types. Types covered include:

  • Pistons
  • Diaphragm
  • Helical Screw
  • Slide propeller
  • Scrolling
  • Rotary Lobe
  • Centrifugal
  • Axial

How to use an air compressor

  1. Position the Air Compressor
  2. Check the Oil Level
  3. Check the Drain Valve
  4. Set the PSI
  5. Prepare the Air Tank
  6. Connect the Air Hose
  7. Connect the Desired Tool
  8. Remove Excess Moisture

You can learn more about compressor here brainly.com/question/26581412

#SPJ4

7 0
1 year ago
(50 points) What animes should I watch?
Eddi Din [679]

Answer:

naruto,naruto shippuden and baruto

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Match each task with the features necessary to complete the task
    10·1 answer
  • Before his job interview, Shabnam took the time to carefully wash and iron his best khaki pants and a button-down shirt. He even
    15·2 answers
  • Purpose: This application provides experience with user input and interaction in the Console, writing files to disk, working wit
    9·1 answer
  • Who invented the machine known as colossus?
    9·2 answers
  • list the six external parts or "peripherals" of a computer system and identify which are output and which are input devices.
    15·1 answer
  • Program 7 - Circle You write ALL the code, then run it - Produce the correct output. Turn in code and screen print of successful
    15·1 answer
  • Google’s adwords system provides a quality score as a measure of _____, which indicates the usefulness of an ad message to consu
    6·1 answer
  • Sara Beth and Taylor have developed a new software that they plan to distribute for free, allowing other software professionals
    7·1 answer
  • Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
    14·1 answer
  • Write the use of these computers.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!