Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #define MAX_

ID: 3702957 • Letter: #

Question

#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #define MAX_STRING_LENGTH 80 using namespace std; int main() { string userInput; cout<<"Please enter a sentence "; cin>>userInput; for (int i = 0; i < userInput.length(); i++) { if (isdigit(userInput[i])) { cout< #include #include #include #define MAX_STRING_LENGTH 80 void main(void) { char userInput[MAX_STRING_LENGTH]; printf("Please enter a sentence "); scanf("%[^ ]", userInput); for (int i = 0; i < strlen(userInput); i++) { if (isdigit(userInput[i])) { printf("%c", userInput[i]); } } printf(" "); system("pause");//from stdlib } I have errors for c ++

Explanation / Answer

#include <stdio.h>
#include <string.h>

#include<stdlib.h>
#define MAX_STRING_LENGTH 80
int main(void) {
char userInput[MAX_STRING_LENGTH];
int i;
printf("Please enter a sentence ");
scanf("%[^ ]", userInput);
for (i = 0; i < strlen(userInput); i++) {
if (isdigit(userInput[i])) {
printf("%c", userInput[i]);

}

}
printf(" ");
system("pause");//from stdlib
return 0;
}

Output: