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
Musya8 [376]
3 years ago
9

Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outpu

ts yes if every character is a digit 0-9. You may assume that the string does not contain spaces and will always contain less than 50 characters.Ex: If the input is:1995the output is:yesEx: If the input is:42,000 or1995!the output is:noHint: Use a loop and the isdigit() function (don't forget to include the ctype library).
Computers and Technology
1 answer:
ANEK [815]3 years ago
7 0

Answer:

#include <stdio.h>

#include <ctype.h>

int main(void) {

char data[50];

int i;

   printf("Enter data: ");

   scanf("%s", data);

 

for (i = 0; data[i] != '\0'; ++i){

 if(isdigit(data[i]) == 0){

  printf("\nno");

  return 0;

 }

}

printf("\nyes");

return 0;

}

Explanation:

Step 1 : Define variables and libraries

  • Variables:

           char data[50];

     int i;

  • Libraries:

           #include <stdio.h>

           #include <ctype.h>

Step 2:  Read the data and asign to variable:

       printf("Enter data: ");

       scanf("%s", data);

Step 3: Loop over the data :

       for (i = 0; data[i] != '\0'; ++i)

Step 4: Validate if the element is digit:

       if(isdigit(data[i]) == 0)

Step 5: If the element is not digit print no and finish the program:

               if(isdigit(data[i]) == 0){

  printf("\nno");

  return 0;

 }

Step 6: If all elements are digits print yes and finish the program:

       printf("\nyes");

return 0;

You might be interested in
Nathan wants to use the Push transition from left to right in his presentation. After he selects the Push transition, what shoul
Vladimir [108]

After he selects the Push transition, He should select from Left option from the Effect Options drop-down menu.

<h3>What is push transition in PowerPoint?</h3>

The Push Transition Effect is known to be a function in a PowerPoint that helps to pushes one slide to show the other.

Note that when this is  applied to any presentation, it moves the current slide upwards to reveal the next slide and so on. A person can add use this kind of effect to present a scrolling effect to one's PowerPoint work.

Learn more about presentation from

brainly.com/question/24653274

8 0
2 years ago
Read 2 more answers
The density of mercury is 13.6 grams per cubic centimeter. Complete the steps for converting 13.6 g/cm3 to kg/m3.
jek_recluse [69]
The density of mercury is 13.6 grams per cubic centimeter. Complete the steps for converting 13.6 g/cm3 to kg/m3.

(1 kg = 1,000 g, 1 m3 = 106 cm3)

13,600
106
1,360
1 g
1 kg
1 m3
7 0
2 years ago
________ is a record in a relational database.
leonid [27]

The answer that is a record in a relational database is called; A row

<h3>What is a record in relational database?</h3>

In relational databases, a record is defined as a group of related data held within the same structure. Furthermore, we can say that a record is a grouping of fields within a table that reference one particular object.

Now, in relational database, a row is called a record because each row, contains a unique instance of data or key for the categories defined by the columns.

Read more about Relational Database at; brainly.com/question/13262352

#SPJ12

4 0
1 year ago
Select all that apply.
Valentin [98]

Answer:

1, 3, & 4.

Is the way to do so. Good luck.

6 0
3 years ago
How do you launch windows on a computer?
alexandr1967 [171]
You shood just be able to tern it on 
5 0
3 years ago
Other questions:
  • To keep your audience interested in your speech, you should provide them with as many details as possible about the topic.
    12·1 answer
  • Emma has decided that she needs to assess the risk and return of buying an extended warranty for her new laptop for school
    15·1 answer
  • When might be the best time to start saving for retirement?
    5·2 answers
  • Which party controlled the White House and politics in the late 1800s, except for Grover
    6·2 answers
  • . What is the relationship between frequency, wavelength and speed of a wave?
    15·1 answer
  • Write an application that determines which, if any, of the following files are stored in the folder where you have saved the exe
    10·1 answer
  • Does white space have visual weight? Yes or No
    7·2 answers
  • when inserting a bibliography one choose from multiple ______ of bibliographies.[insert Bibliography]
    12·1 answer
  • MmfbfMMMMMMMMMMMMMMMMMmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
    14·1 answer
  • The FCFS algorithm is particularly troublesome for ____________.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!