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

My code for number 1 is #include #include int main() { int i = 0; int len = 0; i

ID: 3687892 • Letter: M

Question

My code for number 1 is

#include
#include

int main() {
   int i = 0;
   int len = 0;
   int j = 0;
   char buffer[256];
   char reverse[256];
   printf("Input: ");
   fgets(buffer, 256, stdin);
   //Get length of string
   for (i = 0; buffer[i] != ''; i++) {
       len++;
   }

   for (j = 0, i = len - 2; i >= 0; i--) {
       reverse[j] = buffer[i];
       j++;
   }
   j++;
   reverse[j] = '';
   printf("Output:%s", reverse);
   return 0;

}

When I enter the text I get .neve teg dam teg t'noD? instead of .neve teg dam teg t'noD

What is wrong in my code?

and for question two my code is

#include

struct Student {
   int ID;
   int score;
};

typedef struct Student student;

void init(); //Takes in 3 student’s ID and scores
int score(int ID); //Takes in an ID and return the student’s score
double average(); // return the 3 student’s average score

student stdArray[3];

void init() {
   int index = 0;
   for (index = 0; index < 3; index++) {
       scanf("%d %d", stdArray[index].ID, stdArray[index].score);
   }
}

int score(int ID) {
   int index = 0;
   for (index = 0; index < 3; index++) {
       if (stdArray[index] == ID) {
           return stdArray[index].score;
       }
   }

   printf("ID not found! ");
   return -1;
}

double average() // return the 3 student’s average score
{
   double avg = 0;
   int index = 0;
   for (index = 0; index < 3; index++) {
       avg += stdArray[index].score;
   }
   avg = avg / 3.0;
   return avg;

}

but I get an error at line 26 and it won't run.

Help please.

CDA 3275 Spring 2016 Project 3 Due Date: April 13th (012.1) Write a program that reads a message and prints the reversal of the message Example: (10 points) Input: "Don't get mad, get even." 1. nput: "Don't get mad, get even.' Output: ".neve tag,dam teg t'noD" 2. Define a Student structure that contains a student ID (int type) and scorelint type). You need to implement three functions: (15 points) (1) void init() //Takes in 3 student's ID and scores (2) int score(int ID) /I Takes in an ID and return the student's score (3) double average) // return the 3 student's average score Basically what you need is a global structure array, then in your main function call init function to initialize. Each student's ID and score and separated by space and takes one line, like 123 90 125 80" 68 70 n each line, the first number is ID and the second number is score. So the average) function when called should return 70. And for the score() function, when input ID 125, should return 80 And if it didn't find an ID, should output an error message and return -1;

Explanation / Answer

Answer:

Below is the error free code :

2)

Error Rectification Explanation :

We need to compare the members of the struct to itself always i.e in line

Structs are not valid operands for equality i.e == also the operands have to be a pointer or perform arithmetic operation.

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