diff --git a/C4/correct_answer.c b/C4/Correct_answer/correct_answer.c similarity index 100% rename from C4/correct_answer.c rename to C4/Correct_answer/correct_answer.c diff --git a/C4/wrong_answer.c b/C4/Wrong_answer/wrong_answer.c similarity index 50% rename from C4/wrong_answer.c rename to C4/Wrong_answer/wrong_answer.c index ec78a2a..d5eceb4 100644 --- a/C4/wrong_answer.c +++ b/C4/Wrong_answer/wrong_answer.c @@ -3,15 +3,18 @@ int main(void) { - // Declare and initialiase as required + // Declare and initialise as required int a = 1,b = 4; float ans; - ans = a / b; // Perform calculation + // Perform calculation + // a and b are integers so the answer will be the result of the integer division + + ans = a / b; // Display answer printf ("\nThe answer is %f",ans); - - // Exit from program + return 0; + } \ No newline at end of file diff --git a/C4/poor_layout.c b/C4/poor_layout/poor_layout.c similarity index 100% rename from C4/poor_layout.c rename to C4/poor_layout/poor_layout.c diff --git a/C5/formatting_numbers.c b/C5/FormattingNumbers/formatting_numbers.c similarity index 100% rename from C5/formatting_numbers.c rename to C5/FormattingNumbers/formatting_numbers.c diff --git a/C7/getchar_example.c b/C7/Getchar/getchar_example.c similarity index 91% rename from C7/getchar_example.c rename to C7/Getchar/getchar_example.c index ecc93b0..4f26421 100644 --- a/C7/getchar_example.c +++ b/C7/Getchar/getchar_example.c @@ -6,6 +6,7 @@ int main(void) // declare variable char c; + printf("Input a character: "); // Wait for a kepypress, store result in c c = getchar(); diff --git a/C7/scanf_example_1.c b/C7/Scanf1/scanf_example_1.c similarity index 100% rename from C7/scanf_example_1.c rename to C7/Scanf1/scanf_example_1.c diff --git a/C7/scanf_example_2.c b/C7/Scanf2/scanf_example_2.c similarity index 100% rename from C7/scanf_example_2.c rename to C7/Scanf2/scanf_example_2.c diff --git a/LC10/simple_functions_1.c b/LC10/SimpleFunctions1/simple_functions_1.c similarity index 95% rename from LC10/simple_functions_1.c rename to LC10/SimpleFunctions1/simple_functions_1.c index 058d7ab..d94ecc5 100644 --- a/LC10/simple_functions_1.c +++ b/LC10/SimpleFunctions1/simple_functions_1.c @@ -13,12 +13,7 @@ */ -float CalculateAreaOfCircle ( float radius ) -{ - float area; - area = M_PI * radius * radius ; - return (area) ; -} +float CalculateAreaOfCircle ( float radius ); /* Show use of function */ @@ -45,3 +40,10 @@ int main (void) // All done return 0; } + +float CalculateAreaOfCircle ( float radius ) +{ + float area; + area = M_PI * radius * radius ; + return (area) ; +} \ No newline at end of file diff --git a/LC10/simple_functions_2.c b/LC10/SimpleFunctions2/simple_functions_2.c similarity index 95% rename from LC10/simple_functions_2.c rename to LC10/SimpleFunctions2/simple_functions_2.c index 3b70441..46ec4ab 100644 --- a/LC10/simple_functions_2.c +++ b/LC10/SimpleFunctions2/simple_functions_2.c @@ -32,8 +32,8 @@ int main (void) // Prompt for and obtain values printf ("Please enter the radius of the cylinder: "); scanf ("%f", &rad); -ad - printf ("Please enter the length of the cylinder: "); + + printf ("Please enter the length of the cylinder: "); scanf ("%f", &len); // Use our function to calculate the area diff --git a/LC12/global_ex1.c b/LC12/Global1/global_ex1.c similarity index 100% rename from LC12/global_ex1.c rename to LC12/Global1/global_ex1.c diff --git a/LC12/global_ex2.c b/LC12/Global2/global_ex2.c similarity index 100% rename from LC12/global_ex2.c rename to LC12/Global2/global_ex2.c diff --git a/LC12/global_ex3.c b/LC12/Global3/global_ex3.c similarity index 100% rename from LC12/global_ex3.c rename to LC12/Global3/global_ex3.c diff --git a/LC21/simple.c b/LC21/Simple/simple.c similarity index 100% rename from LC21/simple.c rename to LC21/Simple/simple.c diff --git a/LC5/printf_example.exe b/LC5/printf_example.exe deleted file mode 100644 index 6e6e745..0000000 Binary files a/LC5/printf_example.exe and /dev/null differ diff --git a/LC7/fgets_string.c b/LC7/FgetsString/fgets_string.c similarity index 76% rename from LC7/fgets_string.c rename to LC7/FgetsString/fgets_string.c index a6471c1..677f8c0 100644 --- a/LC7/fgets_string.c +++ b/LC7/FgetsString/fgets_string.c @@ -8,13 +8,13 @@ int main() { - char MyName[50]; /* Define a string of 10 characters */ + char MyName[11]; /* Define a string of 10 characters */ /* A string */ printf("\nPlease enter your name & press return "); - fgets(MyName, 80, stdin); + fgets(MyName, 11, stdin); printf("\nHello %s ",MyName); return 0; /* End of the program */ diff --git a/LC7/getch.c b/LC7/Getch/getch.c similarity index 85% rename from LC7/getch.c rename to LC7/Getch/getch.c index 98f7990..d92a07f 100644 --- a/LC7/getch.c +++ b/LC7/Getch/getch.c @@ -15,9 +15,10 @@ int main(void) char x; /* Define a variable of type char */ + printf("Input a character: "); x = getch(); /* Use getchar to read a keypress and store the */ /* result in 'x' */ - + printf("\nDisplaying the char with putchar: "); putchar(x); /* Display the character stored in 'x' on the */ /* screen using putchar */ diff --git a/LC7/gets_string.c b/LC7/GetsString/gets_string.c similarity index 84% rename from LC7/gets_string.c rename to LC7/GetsString/gets_string.c index 2a7c94b..c4f15a8 100644 --- a/LC7/gets_string.c +++ b/LC7/GetsString/gets_string.c @@ -8,7 +8,7 @@ int main( void ) { - char MyName[50]; /* Define a string of 10 characters */ + char MyName[10]; /* Define a string of 10 characters */ /* A string */ diff --git a/LC7/scanf_string.c b/LC7/ScanfString/scanf_string.c similarity index 100% rename from LC7/scanf_string.c rename to LC7/ScanfString/scanf_string.c diff --git a/LC8/complex_if.c b/LC8/ComplexIf/complex_if.c similarity index 94% rename from LC8/complex_if.c rename to LC8/ComplexIf/complex_if.c index 3d70e30..8839daa 100644 --- a/LC8/complex_if.c +++ b/LC8/ComplexIf/complex_if.c @@ -1,4 +1,4 @@ -/* EEEE1001/H61CAE Chapter 8 */ +/* MMME3085 Chapter 8 */ /* Example of a simple if statements */ diff --git a/LC8/if_else_if_else.c b/LC8/IfElseIfElse/if_else_if_else.c similarity index 91% rename from LC8/if_else_if_else.c rename to LC8/IfElseIfElse/if_else_if_else.c index 40bb1bf..d3dcf7d 100644 --- a/LC8/if_else_if_else.c +++ b/LC8/IfElseIfElse/if_else_if_else.c @@ -11,7 +11,7 @@ int main( void ) { - int x = 55; // Define and intialise variable + int x = 3; // Define and intialise variable if ( x == 2 ) diff --git a/LC8/if_equals_example.c b/LC8/IfEquals/if_equals_example.c similarity index 95% rename from LC8/if_equals_example.c rename to LC8/IfEquals/if_equals_example.c index 659589c..f3047e1 100644 --- a/LC8/if_equals_example.c +++ b/LC8/IfEquals/if_equals_example.c @@ -1,4 +1,4 @@ -/* EEEE1001/H61CAE Chapter 8 */ +/* MMME3085 Chapter 8 */ /* Incorrect use of a single equals sign in an if statement */ diff --git a/LC8/if_examples.c b/LC8/IfExamples/if_examples.c similarity index 100% rename from LC8/if_examples.c rename to LC8/IfExamples/if_examples.c diff --git a/LC8/switch_1.c b/LC8/Switch1/switch_1.c similarity index 94% rename from LC8/switch_1.c rename to LC8/Switch1/switch_1.c index 65afe5e..114108e 100644 --- a/LC8/switch_1.c +++ b/LC8/Switch1/switch_1.c @@ -1,4 +1,4 @@ -/* EEEE1001/H61CAE Chapter 8 */ +/* MMME3085 Chapter 8 */ /* Example of a simple if statements */ diff --git a/LC8/switch_2.c b/LC8/Switch2/switch_2.c similarity index 89% rename from LC8/switch_2.c rename to LC8/Switch2/switch_2.c index 76719cf..4a0c08f 100644 --- a/LC8/switch_2.c +++ b/LC8/Switch2/switch_2.c @@ -12,7 +12,7 @@ int main( void ) { char c; /* Define an char */ - c = getch(); /* Get value - no return required*/ + c = getch(); /* Get value */ switch (c) /* Start of switch */ { diff --git a/LC8/switch_3.c b/LC8/Switch3/switch_3.c similarity index 100% rename from LC8/switch_3.c rename to LC8/Switch3/switch_3.c diff --git a/LC9/do_while_example.c b/LC9/DoWhile/do_while_example.c similarity index 100% rename from LC9/do_while_example.c rename to LC9/DoWhile/do_while_example.c diff --git a/LC9/for_loops.c b/LC9/ForLoops/for_loops.c similarity index 84% rename from LC9/for_loops.c rename to LC9/ForLoops/for_loops.c index 54bccc5..3ee4e10 100644 --- a/LC9/for_loops.c +++ b/LC9/ForLoops/for_loops.c @@ -29,6 +29,7 @@ int main(void) for ( j = 0 ; j < 10 ; j++ ) printf("\nThe value of j is %d",j ); + printf("\nThe value of j after increment loop is %d",j); /* The count down loop */ @@ -36,6 +37,7 @@ int main(void) for ( j = 10 ; j > 0 ; j-- ) printf("\nThe value of j is %d",j ); + printf("\nThe value of j after decrement loop is %d",j); return 0; diff --git a/LC9/while_example_version_1.c b/LC9/While1/while_example_version_1.c similarity index 100% rename from LC9/while_example_version_1.c rename to LC9/While1/while_example_version_1.c diff --git a/LC9/while_example_version_2.c b/LC9/While2/while_example_version_2.c similarity index 100% rename from LC9/while_example_version_2.c rename to LC9/While2/while_example_version_2.c