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 type of security threat installs to a computer without the user's knowledge and then monitors all computer activity?
STatiana [176]
That would be what is known as Spyware, a common form of this is known as a "Trojan Horse". This type of malware is typically latched on and hidden within files, such as when downloading a pirated version of a song, game, art-work, etc...
3 0
3 years ago
Read 2 more answers
whats something that u want to do but ur parents wont allow it like having a phone or going to a college ​
den301095 [7]

Answer:

getting a motorcycle and getting a tattoo

6 0
3 years ago
Read 2 more answers
To use an imported image, simply drag it from the desktop onto the stage. true or false?
elena-s [515]

Answer:

True

Explanation:

Because i have done it before and it works on an accer

6 0
4 years ago
80% OF QUESTIONS ARE ANSWERED IN UNDER 10 MINUTES why not mine
Lilit [14]

Which question do u need and plus some people just go for quick questions

6 0
3 years ago
Read 2 more answers
What are variables in Q Basic programs​
AlexFokin [52]

Answer:

1. Numeric variable:

A variable which can store numeric value is called numeric variable.

e.g.

A=12

pi=3.14

c=79.89

2. String variable:

A variable which can store string variable is called String variable. String is a array of character enclosed within the double inverted comma.

e.g.

N$="ram"

Place$="Kirtipur Kathmandu"

note that a string variable ends with $

Explanation:

A variable is a quantity which can store value in computer memory. A variable is also a quantity whose value changes during the execution of a program. Like in mathematics a variable holds certain value Just in QBASIC; it is a placeholder for storing value in computer memory

4 0
3 years ago
Other questions:
  • Few people will care if you use their image in a photograph without obtaining their consent. True False
    10·1 answer
  • What must you do first in order to change the font type size and colour of a particular text
    13·2 answers
  • Criminal Investigation people called my house on an automated voice is this a scam ??
    13·1 answer
  • Apart from confidential information, what other information does NDA help to outline?
    15·1 answer
  • Select a classification for File2 so that: Alice can read and write to File2 Bob and Charlie can write to File2, but can't read
    6·1 answer
  • How does LinkedIn differ from other popular social media platforms? What are the similarities?
    6·1 answer
  • - Explain the Windows User Authentication process for Client connecting to the domain
    11·1 answer
  • What is the main purpose of a web crawling program
    15·1 answer
  • Please help ASAP!
    7·2 answers
  • Only need help on f and correct me if im wrong for the other questions please
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!