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

The Assignment should be delivered in C language Program 5 will prompt the user

ID: 3846178 • Letter: T

Question

The Assignment should be delivered in C language

Program 5 will prompt the user for one or two token, space delimited, inputs of at most 65 characters. If the user inputs too many characters or an incorrect number of tokens the appropriate error messages should be printed. The program should prompt the user until the single STR token "quit" is entered. The program will only accept two token inputs of the type:STR INT and single token inputs of the type:STR, which should result in the token types being printed as before (Program 4). All other inputs should be rejected with the appropriate (provided) error message. > 1 2 3 ERROR! Incorrect. number of tokens found. > 1 2 ERROR! Expected STR INT. > 1 ERROR! Expected STR. > Stuff STR. > tuff 1 STR INT

Explanation / Answer

#include<stdio.h>

#include<string.h>

int main(){

int n;

String s;

char c[3]={''};

printf("Enter only integer and String");

while((scanf("%d",&n)||scanf("%s",s))!=1){

printf("please enrter only integer or string");

}

char text[65]=s;

while(text){

if(strlen(text)<65){

char *token=strtok(text," ");

puts(token);

}

else{

printf("String size is large");

}

}

printf("enter STR to stop reading");

while(strcmp(text,'STR')){

printf("program terminated");

}

getchar();

return 0;

}