Hi all,
I got to write a program, which allow user to enter the name, and it will generate two numbers from 0-100, and calculate the average of it.
And i will to hack the program so the average can always be the highest which is 100.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
srand(time(NULL));
char input[8];
printf("Please enter the student name: ");
gets(input);
int score1=rand()%100+1;
int score2=rand()%100+1;
float average = (score1+score2) / (float)2;
printf("Your name is: %s", input);
printf("\nYour first mark is: %d ", score1);
printf("\nYour secord mark is: %d", score2);
printf("\nAnd the averge mark is: %f\n", average);
return 0;
}
Any experts know how to hack the average?
Thanks,
Eddie