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
What is the input for air cooler computer science​
Maru [420]

Answer:

cooling

Explanation:

Air cooling is a process of lowering air temperature by dissipating heat. It provides increased air flow and reduced temperatures with the use of cooling fins, fans or finned coils that move the heat out of a casing such as a computer …

5 0
2 years ago
Matt goes to an Internet café and tries to access his emails. The email client asks Matt to enter his email address along with t
Radda [10]

Answer:

acknowledging

Explanation:

it has to be d

6 0
3 years ago
Where is the start frame delimiter found in the Ethernet frame
Ksju [112]
Answer: The SFD is the eight-bit (one-byte) value that marks the end of the preamble, which is the first field of an Ethernet packet, and indicates the beginning of the Ethernet frame.
8 0
3 years ago
How many different bit strings are there of length 8 that contain the string 0000?
Nataly_w [17]

Answer:

answer is 8! / (4! * 4!). Which gives a value of 70.

Explanation:

we have 8 places, we’re going to pick 4 places to put the zeros, it is 8! / (4! x 4!)

3 0
2 years ago
Merge sort has a o(n log2(n)) complexity. if a computer can sort 1,024 elements in an amount of time x, approximately how long w
Musya8 [376]
<span>1,048,576 is 1,024 times 1,024, 1,024 * 1,024 or 1,024 squared or 1,024^2. If a computer takes x amount of time to sort 1,024 elements then the relationship is a 1 to 1. Therefore the computer will take x times x or x^2 (x squared) amount of time to sort 1,048,576.</span>
6 0
3 years ago
Other questions:
  • From the ages of 18 to 24, individuals born from 1980 to 1984 held an average of 6.2 jobs—which is slightly higher than the numb
    10·1 answer
  • How to cancel branly subscription??​
    8·1 answer
  • I live in Alabama and I’m ab to leave to go on a 3 week trip to France and I’m wondering how I can get LTE for my IPhone 6s Plus
    15·2 answers
  • In a non-price rationing system, consumers receive goods and services first-come, first served. Give me an example of a time whe
    8·1 answer
  • The AND operator is a disjunction and the OR operator is a conjunction.
    15·1 answer
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of cust
    5·1 answer
  • Price of ETH coin right now?<br> Don't answer if u don't know.
    12·1 answer
  • Firestick optimizing system storage and applications
    14·1 answer
  • Pls say correct guyz pls pls pls
    7·1 answer
  • What are two reasons a network administrator would use cdp.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!