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
Which type of protocol provides a way to transfer files from one computer to another over any tcp/ip network, such as a lan or t
Alexxandr [17]

Answer:

FTP (File Transfer Protocol) is a network protocol for transmitting files between computers over Transmission Control Protocol/Internet Protocol (TCP/IP) connections. Within the TCP/IP suite, FTP is considered an application layer protocol.

Explanation:

hope it helps you mark me as brainlist and follow me

4 0
2 years ago
___ are controls through which a user can enter input data in a gui application. answer
BaLLatris [955]
Digital data<span>. Biometric </span>data<span>. Digital </span><span>data</span>
5 0
3 years ago
The operating cost of driving include
blagie [28]
And what is the question?
4 0
3 years ago
A company is experiencing overwhelming visits to a main web server. The IT department is developing a plan to add a couple more
Varvara68 [4.7K]
The answer is C) Availability.

Although the company is addressing scalability by adding more servers, the question is asking for security requirement. Therefore we need to choose one of the principles from CIA triad which includes confidentiality, integrity, and availability.

Integrity involves keeping the data accurate and confidentiality involves keeping the data between the sender and intended recipient(s). That being said, scalability and availability are the possible answers.

C) Availability is the best answer because it is part of the CIA triad.

Note: Another resource to look at for cyber security principles would be the Parkerian Hexad.
5 0
3 years ago
Read 2 more answers
FTP is commonly used to __________ and __________ files to a server.
Aleks [24]

Answer:

upload; download

Explanation:

FTP (File Transfer Protocol) is an internet protocol used to upload and download a file to a server, there are some programs help us to transfer this data to a server, in some cases, we're going to need these programs to upload website files to the server like images or videos, or some websites where do you need a user and passwords to upload file by FTP

8 0
3 years ago
Other questions:
  • Apart from confidential information, what other information does NDA help to outline?
    15·1 answer
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • Computing devices translate digital to analog information in order to process the information
    8·1 answer
  • Where can I watch infinity war for free?
    9·1 answer
  • What fields of engineering are in Biomedical
    7·1 answer
  • A ____ is a battery-operated power source directly attached to one or more devices and to a power supply (such as a wall outlet)
    14·1 answer
  • Hi whats airpods good for
    15·2 answers
  • What is the reasoning you would write an inquiry to a company?
    5·2 answers
  • Pls help I will give points
    7·1 answer
  • In attempts to improve their contribution to the environment a company decides to adapt green computing. Which of these techniqu
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!