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

I need help fixing the error in my C programming code. #include <stdio.h> #pragm

ID: 662351 • Letter: I

Question

I need help fixing the error in my C programming code.

#include <stdio.h>

#pragma warning(disable: 4996)

// Forward Declarations
int CaseOne(int, char*);
int CaseTwo(int, char*);
char* CaseThree(int, char*);
char* CaseFour(int, char*);
void CaseFive(int, char*);

// DO NOT CHANGE MAIN FUNCTION
void main() {
   int       value;
   char   CaseOneErrorType[256],
           CaseTwoErrorType[256],
           CaseThreeErrorType[256],
           CaseFourErrorType[256],
           CaseFiveErrorType[256];
  
   printf("Please enter an integer number between 65 to 90: ");
   scanf("%d", &value);

   printf("Initial state: %d Result: %d ", value, CaseOne(value, CaseOneErrorType));
   printf("Initial state: %d Result: %d ", value, CaseTwo(value, CaseTwoErrorType));
   printf("Initial state: %d Result: %s ", value, CaseThree(value, CaseThreeErrorType));
   printf("Initial state: %d Result: %s ", value, CaseFour(value, CaseFourErrorType));
  
   CaseFive(value, CaseFiveErrorType);
}


// Expected Result: double the value (ex: Value = 10, Result = 20)
int CaseOne(int value, char* ErrorType) {

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");

   return 2 * Value;
}

// Fix the error
// Expected Result: value ^ 2 (ex: Value = 20, Result: 400)
int CaseTwo(int value, char* ErrorType) {
   int result = 0;

   for (int index = 0; index > value; index++) {
       result += value;
   }

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");

   return result;
}

// Fix the error
// Expected Result: determine if value is even or odd (ex: Value = 11, Result = The inputted value is odd.)
char* CaseThree(int value, char* ErrorType) {
   char result[256];

   if (value % 2) {
       strcpy(result, "The inputted value is even.");
   }
   else {
       strcpy(result, "The inputted value is odd.");
   }

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");

   return result;
}


// Expected Result: determine if the decimal value correspond to an alphabetic character.
// (ex: Value = 66, Result = "This is an alphabetic character.")
char* CaseFour(int value, char* ErrorType) {

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");

   if ((65 <= value <= 90) || (97 <= value <= 122))
       return "This is an alphabetic character.";
   else
       return "Invalid character.";
}


// Expected Result: Print the phrase, "Hello World - n", n number of times.
// (ex: Value = 0, Result = "")
// (ex: Value = 2, Result = "Hello World - 1"
//                           "Hello World - 2")
void CaseFive(int value, char* ErrorType) {
   int index = 0;

   do {
       printf("Hello World - %d ", index);
   } while (index < value);

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");
}

Explanation / Answer

}

char* CaseThree(int value, char* ErrorType) {
   char result[256];

   if (value % 2==0) {
       strcpy(result, "The inputted value is even.");
   }
   else {
       strcpy(result, "The inputted value is odd.");
   }

   // What type of error? (Syntactic, Semantic, or Contextual)
   strcpy(ErrorType, "RESPONSE");

   return result;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote