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
saw5 [17]
3 years ago
6

Write a C program that reads a string containing text and nonnegative numbers from the user and prints out the numbers contained

in the string in separate lines. For example, if the input is: The year has 365 days and the day has 12 hours Then the output will be: 365 12
Computers and Technology
1 answer:
Alex_Xolod [135]3 years ago
6 0

Here is the code in C.

#include <stdio.h>

#include <string.h>

//main function

void main()

{

// character array to store the string

char str[1000];

int len,i,j;

char c,ch;

printf("Please Enter a string: ");

 // read the string

gets(str);

// find the length of input string

len = strlen(str);

for(i=0;i<len;i++)

 {

      c=str[i];

       // if any character of string is digit then it will check

       // until it finds the next non-digit character

     if(c>='0' && c<='9')

     {

         for(j=i;j<len;j++)

         {

             ch=str[j];

             if(ch>='0' && ch<='9')

              //print the number in the string

             printf("%c",str[j]);

             else

             {

                 printf(" ");

                 i=j;

                 break;

             }

         }

     }

 }

}

Explanation:

First it ask user to input a string and store that string into character array.Then travers the array and find first digit character.If a digit is found then print that digit.After that in the inner for loop, check next character is digit or not, if a digit meets then print that digit.Repeat this until the next non-digit character founds.When a non-digit character meets print a space and update the value of "i" and break the inner loop.It will again check the same from the ith index in the character array.

Output:

Please Enter a string: The year has 365 days and the day has 12 hours

365 12

You might be interested in
Beth would like to run an nmap scan against all of the systems on her organization's private network. These include systems in t
Natasha_Volkova [10]

Answer:

<em>B. 10.0.0.0/8. </em>

Explanation:

Using an 8-bit subnet mask ensures the <em>network address is represented by the first octet of the IP address and is very efficient.</em>

The suffix /8 implies that Beth checks all devices in the 10.0.0.0 network (hosts between 10.0.0.0 and 10.255.255.255).

8 0
3 years ago
What part of the boot-up process initializes hardware and finds an operating system to load?
igomit [66]
The part where it checks for the boot order, because the boot order is telling the system, what hardware to research and boot.
5 0
3 years ago
When spraying pesticide wear and protective eyeglass​
exis [7]
Ummmmmmmmmmmmmmmmmmmmm ok
6 0
3 years ago
Read 2 more answers
"A(n) ___________ is a radio transceiver that plays the same role as a hub or switch in a wired network and connects the WLAN to
Alexeev081 [22]

Answer: A central wireless access point (AP)

Explanation:

A central wireless access point (WAP) is a hardware device which can be configured on a local area network connecting WLAN to the wired network.

These APs have built in routers which enables wireless devices to connect with it. Mostly they are hardwired to devices such as in network switches or modems.

These access points are found in many institutions, organisations, enterprises which enables devices to be connected to them and provides access to the internet and resources.

There are also public access points which enables people travelling by public transport to connect through them and in many business organisation there are closed APs for use only by the employees of them which enables file sharing and information processing.

7 0
3 years ago
What is a fax machine used for
pickupchik [31]

Answer:

A fax machine is used to send documents over a phone network.

Explanation:

The transmission that is sent is called "Faxes"

The easiest way to understand this is by having one person print a document at someone else's house. It is also a live time like a telephone, or like a text message.

4 0
3 years ago
Other questions:
  • The purpose of hazard lights is to
    7·2 answers
  • What is the purpose of a title slide on power point
    14·2 answers
  • Write a Java program that prompts the user to enter a sequence of non-negative numbers (0 or more), storing them in an ArrayList
    5·1 answer
  • The function below takes two parameters: a string parameter: CSV_string and an integer index. This string parameter will hold a
    14·1 answer
  • Explain the saying "Dress for the position you want, not the position you have."
    6·2 answers
  • Which 3D game has Bentley the Bear collect gems while avoiding enemy trees, bees, ghosts, skeletons, and Berthilda the witch?
    9·1 answer
  • For each part create a vector n in which the first element is 1, the increment is 1 and the last term is 5, 50, or 5,000. Then u
    13·1 answer
  • Hey does anyone know the name of that movie where like this teenage girl is chilling at her house then there is an outbreak of s
    6·1 answer
  • Write an algorithm to find the average of three numbers: 10, 20, 30
    7·1 answer
  • I found a brand-new charger wire still in its plastic package, but it's six years old and has never been used. Is it safe to use
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!