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
Which description best applies to a macro?
Mama L [17]

A macro is that pseudo-program that performs a list of actions based on a set of instructions.

<h3>What is macro?</h3>

A macro can be said to be a number of commands that help you to get complex things done via automating simple and via repetitive tasks.

A macro is that pseudo-program that performs a list of actions based on a set of instructions.

Therefore, option A is correct as the macros does a whole lot of work.

Learn more about macro from

brainly.com/question/20050035

#SPJ1

6 0
2 years ago
What best describes a firewall
Alona [7]
A firewall is a programmed software that can be activated through setting. a firewall is designed to protect the computer from viruses and malware etc. 
I personally hate it because it is always saying games from game jolt and even steam games are dangerous. hope i helped
8 0
3 years ago
Which option is correct??
Andru [333]

Answer:

a

Explanation:

intercultural communication is about enganging oneself within a social enviroment of foreign culture and different races among it.

3 0
4 years ago
A student has completed some work at school and wishes to take it home. He could use a pen
photoshop1234 [79]

Answer:

what is that I don't understand I am from china

6 0
3 years ago
4
WITCHER [35]
B.
MARK KE BRAINLEST
8 0
3 years ago
Other questions:
  • Which part of an I-statement involves a description of your needs or feelings?
    12·1 answer
  • What is the value of this expression?
    6·1 answer
  • What does the e in email stand for
    8·2 answers
  • Gary lives in an area that receives a lot of rain throughout the year. which device would be useful to him to maintain his compu
    8·1 answer
  • Cellular digestion associated by what organelles?​
    5·2 answers
  • A Windows user right-clicks on his desktop. What is he planning to do?
    10·1 answer
  • <img src="https://tex.z-dn.net/?f=%20%3Cmarquee%20behavior%3D%E2%80%9Dscroll%E2%80%9D%20direction%3D%E2%80%9Ddown%E2%80%9D%3EFol
    9·1 answer
  • What does route print do?
    15·1 answer
  • Puede existir la tecnologia sin la ciencia y sin las tecnicas,explique si o no y fundamente el porque de su respuesta
    11·1 answer
  • I just need question 2 answered. Someone please help I’m on a test!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!