Question
In C
Set hasDigit to true if the 3-character passCode contains a digit. 1 #include «stdio.h> 2 #include«string.h> 3 #include «stdb
4 #include <ctype.h> 6 int main (void) 1 8 char passCode [50]; bool hasDigit; hasDigit- false; 10 11 scanf(%s,&passcode); 1
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Answer:
Replace line 13 with below line of code

hasDigit = isdigit(passCode[0]) || isdigit(passCode[1]) || isdigit(passCode[2]);
Add a comment
Know the answer?
Add Answer to:
In C Set hasDigit to true if the 3-character passCode contains a digit. 1 #include «stdio.h>...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3.14.1: String with digit. Set hasDigit to true if the 3-character passCode contains a digit. HELP...

    3.14.1: String with digit. Set hasDigit to true if the 3-character passCode contains a digit. HELP ME FIX THIS #include <iostream> #include <string> #include <cctype> using namespace std; int main() { bool hasDigit; string passCode; hasDigit = false; cin >> passCode; for(int i=0;i<passCode.length();i++) { if(isdigit(passCode[i])) { hasDigit=true; break; } } if (hasDigit) { cout << "Has a digit." << endl; } else { cout << "Has no digit." << endl; } return 0; }

  • can u please solve it in c++ format,,,, general format which is #include<stdio.h> .......printf and scanf...

    can u please solve it in c++ format,,,, general format which is #include<stdio.h> .......printf and scanf format dont worry about the answers i have down Q3, What is the output of the program shown below and explain why. #include #include <stdio.h> <string.h> int main(void) ( char str[ 39764 int N strlen(str) int nunj for (int i-0; i t Nǐ.de+ printf(") num (str[] 'e); I/ digits range in the ASCII code is 48-57 if (nue > e) f 9 printf( Xdin,...

  • This is C++ I only can change the lines highlighted in white (i can add lines...

    This is C++ I only can change the lines highlighted in white (i can add lines to it with enter though) Set hasDigit to true if the 3-character passCode contains a digit. 1 #include <iostream» 2 #include <string> 3 #include <cctype> 4 using namespace std; 6 int main 7 bool hasDigit; 8 string passCode; 10 hasDigit false; 11 cin passCode; 12 13 Your solution goes here 14 15 if ChasDigit) 16 cout << "Has a digit." < endl; 17 18...

  • Question 6 Predict the output of the following question: 8 pts #include <stdio.h> #include<string.h> char al(5)={...

    Question 6 Predict the output of the following question: 8 pts #include <stdio.h> #include<string.h> char al(5)={ "gate", "kate","rate","date" ); void rec(char a[][5], int n){ if(n<= 1) return; char temp[5]; strcpy(temp'a);//copies the string stored in a into temp strcpy(*a,a[n-1]); strcpy(a[n-1),temp); rec(a+1,n-2); } void main() { rec(a 4); int i = 0; for(;i<4;i++) a[i][4]+= 10; printf("%s", a); }

  • #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here....

    #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } }    return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...

  • Output all combinations of character variables a, b, and c. If a x,b-y, and c z, then the output ...

    write solution to the program above in C please and thank you. Output all combinations of character variables a, b, and c. If a x,b-y, and c z, then the output is Your code will be tested in three different programs, with a, b, c assigned with Χ. 'y', 'z', then with #. 'S. %, then with T, 23 1 #include 3 int main(void) { char a char b; char c; 4. 7 scanf(" scanf(" scanf(" %c %c %c ",...

  • #include <stdio.h> #include <string.h> #define WORDLEN 20 char smallest_word[WORDLEN + 1], largest_word[WORDLEN + 1], word[WORDLEN +...

    #include <stdio.h> #include <string.h> #define WORDLEN 20 char smallest_word[WORDLEN + 1], largest_word[WORDLEN + 1], word[WORDLEN + 1]; void get_first_word(void); void get_another_word(void); void get_word(void); int main(void) { get_first_word(); while (strlen(word) != 4) get_another_word(); printf("\nSmallest word: %s\nLargest word: %s\n", smallest_word, largest_word); return 0; } void get_first_word(void) { get_word(); strcpy(smallest_word, word); strcpy(largest_word, word); } void get_word(void) { printf("Enter word: "); scanf("%20s", word); } void get_another_word(void) { get_word(); if (strcmp(word, smallest_word) < 0) strcpy(smallest_word, word); else if (strcmp(word, largest_word) > 0) strcpy(largest_word, word); }...

  • Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple...

    Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple encryption methods. It works by shifting all letters in the original message (plaintext) by a certain fixed amount (the amounts represents the encryption key). The resulting encoded text is called ciphertext. Example Key (Shift): 3 Plaintext: Abc Ciphertext: Def Task Your goal is to implement a Caesar cipher program that receives the key and an encrypted paragraph (with uppercase and lowercase letters, punctuations, and...

  • include «stdio.h void displaymenu(void) printf(" printf" Enter Choicen") printf Set (a), Clear (c), Toggle (t)\n"): printf("...

    include «stdio.h void displaymenu(void) printf(" printf" Enter Choicen") printf Set (a), Clear (c), Toggle (t)\n"): printf(" void printbinaryfunsigned char x) int main (int argc, char argvl) r mask atoi(argv[1): unsigned char maskatoi(argv[11): ensigned ahao data - ateilargvl21): char operation if argc 3 printf(" printf" n" printf("usage: %s FristArg SecondArgin", argle)); return;

  • CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput...

    CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput is 'Hello output is: Size of user Input: 5 1 #include <stdio.h> 2 #include <string.h> 4 int main(void) { char user Input[50]; int stringSize; BO scanf("%s", userInput); /* Your solution goes here" printf("Size of user Input: %d\n", stringsize); return ; Run

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT