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
You have been asked to install a WLAN for a small business. You centrally locate the WAP in a large room that contains about 15
sveticcg [70]

Answer:

interference

Explanation:

The most likely reason for the connectivity problems is interference. This interference can be caused by many factors but in this scenario the most likely factor would be the metal studs and all the metal used to create the ceiling/floor. Metal is a huge interference when it comes to wifi signals. Depending on the type of metal and the amount it can greatly diminish the signal strength or even completely prevent the signal from passing to it's destination, regardless of how close the destination device is located.

4 0
3 years ago
To add a picture file to a PowerPoint slide, a usor should first go to the
Murrr4er [49]

How to embed images in Powerpoint?

Click on the Pictures button to open the file browser. Now, browse to where your images are stored and click on them in the file browser. Choose Insert > Pictures on PowerPoint's ribbon, then browse to and choose the images you want to insert. Click on Insert to add them to your current slide

6 0
3 years ago
Which is the last line of defense in a physical security sense?
Deffense [45]

Answer: (A) People

Explanation:

 The physical security system is the basically used in the information system. It is used in the technical and the administrator element in the security system. This is the technology oriented system that is basically used to prevent from the hacking attacks in the system.

So, the people is the last statement of the defense in the physical security as the various security system is basically used by various people.

4 0
3 years ago
Which of the following tabs in the PowerPoint Ribbon is unique to PowerPoint,
dlinn [17]

Answer:

The answer to this question is given below in the explanation section

Explanation:

The correct option for this question is Animation tab.

Animation tab in PowerPoint ribbon is a unique tab that is not found in other office applications such as in word, excel, outlook, publisher etc.

Because in PowerPoint you can use animation to make your slides animated and all animation can be managed and animation-related settings, you can find in the animation tab.

However, other tabs such as Home, Insert, and View are common in all office applications.

7 0
4 years ago
Write an if/else statement that compares the variable age with 65, adds 1 to the variable seniorCitizens if age is greater than
Sliva [168]

Answer:

if( age>=65)

{

seniorCitizens=seniorCitizens+1;

System.out.println("seniorCitizens counting is="+seniorCitizens);

}

else  

{

nonSeniors=nonSeniors+1;

System.out.println("nonSeniors counting is="+nonSeniors);

}

Explanation :  

In the above java program, if age will be more than or equal to 65 so seniorCitizens counting will be increased by 1 and if it will be less than 65 so 1 will be increased in nonSeniors.

7 0
4 years ago
Other questions:
  • The first step in creating photographs with good backgrounds is which of the following? Learning to see the background before ta
    11·2 answers
  • What does the "e" in eSATA stand for?
    13·2 answers
  • Write a program that reads a file containing text. Read each line and send it to the output file, preceded by line numbers. If t
    8·1 answer
  • If Phil is putting exact phrases in quotation marks while searching for information, he's using which of the following?
    14·1 answer
  • Sue needs to add a header and a footer to a presentation. Which process should she use to do this?
    10·2 answers
  • Write an if statement that that decreases the variable shelfLife by 4 if the variable outsideTemperature is greater than 90. Ass
    5·1 answer
  • Suppose L is a LIST and p, q, and r are positions. As a function of n, the length of list L, determine how many times the functi
    8·1 answer
  • Buying a house is most likely a long-term goal for a person of which of these
    9·1 answer
  • Match the index with the value
    14·1 answer
  • How would you write out the Python code to PRINT the answer to 5 times 2?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!