First post on this community. Started auditing some C classes at my university and having trouble with If statements. After staring and changing variations of my code for a few hours I still have yet to figure out why I can't return a value other than one of the "scoring" criteria's I've set. If anyone would be kind enough to tell me where my syntax error occurred or even possible hints as to which section I should re-write, I would be extremely grateful. Also, if my logic could use some brushing up on I would love pointers. Thanks again.
#include <stdio.h>
/* Main function */
int main()
{
int Answer1;
float Answer2;
float Answer3;
int Answer4;
int Answer5;
float Answer6;
int point1;
point1 = 0;
int point2;
point2 = 0;
int point3;
point3 = 0;
int point4;
point4 = 0;
int point5;
point5 = 0;
int point6;
point6 = 0;
char name;
int sum;
int score;
int multiplier1;
int bonus_score;
int counter;
counter = 1;
int x;
x = 1;
int y;
y = 2;
int z;
z = 3;
/*
****************
****************
this is the end of my declaration system, now begins the actual functions.
***************
****************
*/
printf (" Welcome to your career amplitude test! This simple program will tell you how far you'll go in life. \n");
printf (" Remember to write your answer to at least two decimal places. \n \n ");
printf ("1. What is 5 + 27? \n");
scanf ("%i", &Answer1);
printf("2. what is 2.7 - .85? \n");
scanf ("%f", &Answer2);
printf ("3. what is 2.3 - .1 * 4? \n");
scanf ("%f", &Answer3);
printf ("4. what is 123 * 123?\n");
scanf ("%i", &Answer4);
printf ("5. what is 945/5?\n");
scanf ("%i", &Answer5);
printf (" Bonus Question!!!!! \n");
printf (" what is the square root of 105487.19? You have 10 seconds to enter a number (not really though.) \n");
scanf ("%f", &Answer6);
/*
******************
******************
after those are printed / scanned it will come up with a potential scoring
system using if statements and if else
*****************
*****************
*/
if ( Answer1 == 32)
{
point1 = 1;
}
else ( Answer1 != 32);
{
point1 = 0;
}
if ( Answer2 == 1.85 )
{
point2 = 1;
}
else ( Answer2 != 1.85 );
{
point2 = 0;
}
if ( Answer3 == 1.9 )
{
point3 = 1;
}
else ( Answer3 != 1.9 );
{
point3 = 0;
}
if ( Answer4 == 15129 )
{
point4 = 1;
}
else ( Answer4 != 15129 );
{
point4 = 0;
}
if ( Answer5 == 189 )
{
point5 = 0;
}
else ( Answer5 != 189);
{
point5 = 0;
}
if ( Answer6 != 324.787 )
{
point6 = 0;
}
if ( Answer6 = 324.787 )
{
point6 = 1;
}
/*
******************
******************
Now to actauly grade the assignment compared to the scoring system just established.
******************
******************
*/
while (counter < 100)
{
counter = counter+x+y+z;
printf("Processing at a light speed rate equal to %i \n \n \n", counter);
}
/* the above is a joke and just wanted to implement a loop for pratice */
printf(" This is your raw score without the Bonus. \n");
sum = (point1 + point2 + point3 + point4 + point5);
score = sum;
if ( score = 0 )
{
score = 0;
printf (" Score: 0 \n");
printf (" You missed every question! \n");
}
else if ( score = 1 )
{
score = 1;
printf (" Score: 1 out of 5 \n");
printf ( " You only got one question right! The world needs ditch diggers too. \n");
}
else if ( score = 2 )
{
score = 2;
printf (" Score: 2 out of 5 \n");
printf ( " You missed 3 questions, pratice your soft skills \n");
}
else if ( score = 3 )
{
score = 3;
printf (" Score: 3 out of 5 \n" );
printf (" I forsee a future in the hedge fund industry \n");
}
else if ( score = 4 )
{
score = 4;
printf (" Score: 4 out of 5 \n ");
printf (" you could probably cook books for Enron \n");
}
else if ( score = 5)
{
score = 5;
printf (" Score: 5 out of 5 \n");
printf (" Go out there and break code for the CIA \n");
}
printf ("With the bonus considered, your score is now \n");
if ( point6 = 1 )
{
multiplier1 = 2;
}
else if ( point6 = 0)
{
multiplier1 = 1;
}
if ( multiplier1 = 2)
{
bonus_score = score * 2;
printf (" %i", bonus_score );
}
else if ( multiplier1 = 1)
{
bonus_score = score;
printf (" You got the Bonus wrong. Nothing new to see here. \n");
}
return 0;
}