![makaylahills1134](/avatars/2063.jpg)
makaylahills1134
23.07.2019 •
Computers and Technology
Two organizations cannot have the same name for a computer true or false
Solved
Show answers
More tips
- C Computers and Internet Dynamically Assigned IP Address: What Is It and How Does It Work?...
- H Health and Medicine Angina: Causes, Symptoms, and Treatment...
- C Computers and Internet How to Learn to Type Fast?...
- F Food and Cooking Delight for Gourmets: How to Prepare Liver Pate...
- S Style and Beauty How to braid friendship bracelets?...
- H Health and Medicine Mercury Thermometer Danger: What to do when a thermometer breaks?...
- F Food and Cooking Which Calamari Salad is the Most Delicious?...
- S Society and Politics 10 Tips for Boosting Your Self-Esteem...
- F Food and Cooking The Most Delicious and Simple Fish in Batter Recipe...
- H Health and Medicine What is Autism? Understanding the Basics of This Neurodevelopmental Disorder...
Ответ:
Ответ:
#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;