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
True or False? A website for a certain political party or candidate is likely to have unbiased information.
kipiarov [429]

<u>False:</u>

A website about anything political from one end such as the political party or candidate is most likely to give biased information such as

  • I will be the best mayor you ever had (Opinion)
  • I will never let you down (Opinion)
  • I have the best house (Opinion)

This is because those are Opinions not facts which is bias-based information.

<em>Hope this helps!</em>

8 0
2 years ago
Read 2 more answers
DES is a commonly used symmetric encryption algorithm, developed in the mid-1990s by the American government in conjunction with
In-s [12.5K]

Answer:

False

Explanation:

The DES encryption standard is believed to be weakened by the American government by containing shortened key lengths and 'S-boxes' of unknown origin.

5 0
2 years ago
The computer uses unallocated space for what​
finlep [7]

A computer uses unallocated space also know as free space to keep a file that has been deleted in its disk until a new file takes it spot and overwrites it.

3 0
3 years ago
Read 2 more answers
you are installing two new hard drives into your network attached storage device your director asks that they be put into a raid
Genrish500 [490]

Question options:

a. RAID 0

b. RAID 1

c. RAID 5

d. RAID 6

e. RAID 10

Answer:

d. RAID 6

Explanation:

RAID is Redundant Array of Inexpensive/Independent Disks. RAID combines low cost physical hard disk drives in one hard disk drive. RAID is used to achieve data redundancy(data backup but with synchronization) or improved performance or both.

To get what the director requires he would need to use RAID 6. RAID 6 is RAID level optimized to achieve data redundancy but with slow performance.

7 0
2 years ago
What goes hand and hand with focus? A) company B) non-profit C) business D) organization
Katyanochek1 [597]

Answer:

I think the answer is D but please let me know if i am wrong

Explanation:

8 0
2 years ago
Read 2 more answers
Other questions:
  • Where is the insert function button found in microsoft excel?
    11·1 answer
  • 4. Extrusion tools in Blender® duplicate vertices while keeping the geometry connected with the original vertices. (1 point)
    7·1 answer
  • Enter the value of 5⋅(13.5−4.5). <br> ​
    5·1 answer
  • How can i become an expert in computer and technology?
    15·2 answers
  • What are two types of formulas in Excel
    13·2 answers
  • Software that helps users to communicate with family, friends and business colleagues by posting personal information, status up
    13·2 answers
  • Which is true about TCP and UDP? Choose two answers.
    15·1 answer
  • What two pieces of information would you need in order to measure the masses of stars in an eclipsing binary system?
    9·1 answer
  • Robert gets home from school at 3 p.M. His mom has to leave for her shift at work at 3:15 and she wants him to watch his baby br
    9·1 answer
  • Which of these best represents a call to action?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!