Fix errors in mC example inputs (thanks Markus)

This commit is contained in:
Markus Kopp 2019-03-31 17:13:11 +02:00 committed by Alex Hirsch
parent 14da3497ed
commit 88e52e7828
7 changed files with 30 additions and 17 deletions

View File

@ -1,8 +1,10 @@
int calculateFactorial(int number){
int factorial = 1;
int i = 1;
int factorial;
factorial = 1;
int i;
i = 1;
while (i <= number){
factorial *= i;
factorial = factorial * i;
i = i + 1;
}
return factorial;

View File

@ -33,7 +33,8 @@ int main() {
print_nl();
b = read_int();
int res = gcd(a,b);
int res;
res = gcd(a,b);
print("The greatest common divisor is: ");
print_int(res);

View File

@ -2,7 +2,8 @@
bool is_square(int n)
{
int i = 0;
int i;
i = 0;
while(i*i < n){
if(i*i == n){
return true;

View File

@ -1,5 +1,6 @@
int returnTwo() {
int value = 2;
int value;
value = 2;
return value;
}
@ -13,7 +14,8 @@ bool isOne(int in) {
int main() {
int[42] array;
int[21] arrayTwo;
int i = 0;
int i;
i = 0;
while (i < 21) {
array[i] = i*i;
i = i + 1;
@ -30,7 +32,7 @@ int main() {
if (array[0] == 0) {
print_int(array[0]);
print_nl();
}
}
if (array[1] == 2) {
print_int(0);

View File

@ -31,7 +31,8 @@ int main() {
input = read_int();
print_nl();
bool result = is_palindrome(input);
bool result;
result = is_palindrome(input);
print_int(input);
if (result) {

View File

@ -97,12 +97,13 @@ int main(){
print("give a sequence of 10 numbers to be sorted: ");
print_nl();
int arr_size = 10;
int arr_size;
arr_size = 10;
int i;
i=0;
if (is_int){
int i_arr[arr_size];
int[10] i_arr;
int i_number;
while(i < arr_size){
print_int(i);
@ -124,7 +125,7 @@ int main(){
print("output array: ");
print_i_array(i_arr, arr_size);
}else{
float f_arr[arr_size];
float[10] f_arr;
float f_number;
while(i < arr_size){

View File

@ -4,8 +4,10 @@ int main(){
print_nl();
int n;
n = read_int();
bool a = 1 <= n;
bool b = 2 == n;
bool a;
a = 1 <= n;
bool b;
b = 2 == n;
b = 3 >= n;
n = n * 2;
n = n / 2;
@ -15,9 +17,12 @@ int main(){
a || b;
a != !b;
int[3] test;
string hi = "Hello";
float f = -1.0;
bool c = true;
string hi;
hi = "Hello";
float f;
f = -1.0;
bool c;
c = true;
if (c)
{
while(c){