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
Anyone knows how to do this??
a_sh-v [17]
I dont know how to do that
4 0
3 years ago
A web designer calls to report that the web server web-s1.cisco is not reachable through a web browser. The technician uses comm
Sergeeva-Olga [200]

Answer:

He can determine if the network is operational with a ping to the IP address.

If this fails, it means this is a DNS issue.

He can also determine if a router is down between the source and the server

Explanation:

A successful ping to IP address indicates that the network is working and the web server is online. Failure means that the host cannot resolve the associated domain name.

Try the web server at 192.168.0.10 is reachable from the source host. A router is down between the source host and the server web-s1.cisco.com. There is a problem with the web server software on web-s1.cisco.com

6 0
3 years ago
How do computers use logic?
madreJ [45]
They don’t use any logic
8 0
4 years ago
Given two int variables distance and speed, write an expression that divides distance by speed using floating point arithmetic,
Vsevolod [243]

Answer:

float(distance) / speed

Explanation:

Given the variable <em>distance</em> and <em>speed</em> in a program that hold a integer value respectively.  We can perform the division between the two variable using / operator. Since both distance and speed are integers, we need to convert one of them to float type to perform the floating point arithmetic. Otherwise the division output will be rounded up to the nearest integer which is not a desired result.

7 0
4 years ago
To save a new copy of an existing database, a user can open the original database and select ________ from the file tab.
Yuri [45]
And select copy from the file tab.
6 0
3 years ago
Other questions:
  • Design the below using an array// Sunrise Freight charges standard// per-pound shipping prices to the five states they serve// –
    6·1 answer
  • A page can have High needs met rating even if it is not related To the topic of the query​
    9·1 answer
  • Evaluate the expression. Be sure to list a value of appropriate type (e.g., 7.0 rather than 7 for a double, Strings in quotes).
    7·1 answer
  • When working in Photoshop with the move tool, you can select multiple layers and use this option to arrange them into a straight
    7·2 answers
  • An OCA previously classified a recent government breakthrough in energy technology as Confidential. The military is developing a
    9·2 answers
  • Multiple Choice
    5·1 answer
  • An ip address contains four sets of numbers what are they called
    11·1 answer
  • Write a number guessing game. The game should have a default 1-100 picking system. Have the user guess the number the computer p
    12·1 answer
  • You are the administrator for a small network with several servers. There is only one printer, which is centrally located. Altho
    10·1 answer
  • Sensory cues are used for script writers to be able to get more creative with the story their are scripting for (i.e.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!