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
What is information richness?
mrs_skeptik [129]

d. Refers to the depth and breadth of details contained in a piece of textual, graphic, audio, or video information.

<h3>Information richness</h3>

Information richness refers to the amount of sensory input available during communication. For example, <u>talking to co-workers in a monotone voice without varying pace or gestures is not a very enriching experience</u>. On the other hand, using gestures, tone of voice, and pace of speech to convey meaning beyond the words themselves promotes richer communication. Different channels have different information wealth.

Information-rich channels convey more non-verbal information. For example, a face-to-face conversation is richer than a phone call, but a phone call is richer than an email. Research shows that effective managers are more likely to use informative channels of communication than ineffective managers.

Learn more about Note-making Information: brainly.com/question/1299137

#SPJ4

4 0
1 year ago
Which of the following files has the Ionic styles? ionic.bundle.css ionic.js ionic.css ionic.bundle.js
Law Incorporation [45]

Answer:

The correct option is ionic.css

Explanation:

Ionic style uses modes to customize the look of components. Each platform has a default mode, but this can be overridden.

And of all the options, only the ionic.css possesses the ionic styles

4 0
3 years ago
Why are magicians gay
AlexFokin [52]

Answer:

Not all of them are

Explanation:

8 0
3 years ago
Read 2 more answers
Write a program to demonstrate doubly linked list using pointers – insert (beginning, end,
Mekhanik [1.2K]

A program to demonstrate doubly linked list using pointers – insert (beginning, end, middle), delete(beginning, end, middle),view) is:

/* Initialize nodes */

struct node *head;

struct node *one = NULL;

struct node *two = NULL;

struct node *three = NULL;

/* Allocate memory */

one = malloc(sizeof(struct node));

two = malloc(sizeof(struct node));

three = malloc(sizeof(struct node));

/* Assign data values */

one->data = 1;

two->data = 2;

three->data = 3;

/* Connect nodes */

one->next = two;

one->prev = NULL;

two->next = three;

two->prev = one;

three->next = NULL;

three->prev = two;

/* Save address of first node in head */

head = one;

<h3>What is a Doubly Linked List?</h3>

This refers to the linked data structure that contains of a set of sequentially linked records called nodes.

The requested program is given above.

Read more about doubly linked list here:

brainly.com/question/13326183

#SPJ1

3 0
1 year ago
Chapter 4 is called Claimed Spaces: ""Preparatory Privilege"" and High School Computer Science. Explain two concepts from chapte
sashaice [31]

Answer: isolation, predominant gender.

Explanation:

Isolation some students felt they were not as smart as their peers and as such were afraid to make contributions because they didn't want to be rediculed by Their peers or tutors.

Predominant gender most calsses are dominated by a certain gender which makes the other gender harbour fears and insecurity

I had difficulty in maths in high school, was always afraid when in class to make contributions because i was insecure, if i had spoken up or met my tutors maybe i would have being better at it

8 0
3 years ago
Other questions:
  • Which of the following is designed to help an organization continue to operate during and after a disruption?
    12·1 answer
  • Which type of text may be formatted to print at the bottom of every page?
    6·1 answer
  • Assume that ip has been declared to be a pointer to int and that enrollment has been declared to be an array of 20 elements . As
    13·1 answer
  • What is a unit to measure loudness
    15·1 answer
  • क) मानौं तिमी बसेको समाजमा मान्छेहरूले सधै फोहर फाल्ने गर्नाले वातावरण प्रदूषित
    13·1 answer
  • Interstate highway numbers Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 of 95) go north/south, an
    8·1 answer
  • What is a fixed expense<br> everfi
    6·1 answer
  • Select the correct answer from each drop-down menu. The following diagram shows four resistors. What is the effective resistance
    9·1 answer
  • Why does 5 g mm wave require more cells to achieve a better signal
    6·1 answer
  • Which description best applies to a macro?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!