tytytyui tytytyui - 1 month ago 7
C++ Question

Trouble error solving

I am new to this site and new to programming. I am taking a class on programming in college and we were given a code to clear of errors. I am having difficulty with this and would like some help, thanks in advance! The main problems I am having is "loop_counter" and "FunctionFoo" being unidentified and int loop_counter = 1; expecting a ';'

#include "stdafx.h"

int UpdateWeatherStation(void)
{
printf("Updating Weather Station\n\n");
int foo = 5;
return foo;
}

void main(void)
{

printf("\nTech104 Lab02\n\n")

int loop_counter = 1;

int xyz = FunctionFoo();
int hjk = FunctionFoo();

while (loop_counter<10)
{

printf("Loop #:%d\n", loop_counter);
int weatherStatus = UpdateWeatherStation();
printf("weatherStatus=%d\n", weatherStatus);
printf("\n\n");

int user_input = getchar();
if (user_input == '5')
{
printf("User entered 5!!!!!\n");
}

loop_counter++;
}
}

int FunctionFoo(void)
{
printf("Hello\n\n");
int abc = 5;

return abc;
}

Answer

your code is full of mistakes:

1- where is the prototype of function FunctionFoo?

2- where is the end of statement ';' after printf() in main?

#include <stdio.h>

int FunctionFoo(void);
int UpdateWeatherStation(void);



void main(void)
{

    printf("\nTech104 Lab02\n\n");

    int loop_counter = 1; 

    int xyz = FunctionFoo();
    int hjk = FunctionFoo();

    while (loop_counter<10)
    {

        printf("Loop #:%d\n", loop_counter);
        int weatherStatus = UpdateWeatherStation();
        printf("weatherStatus=%d\n", weatherStatus);
        printf("\n\n");

        int user_input = getchar();
        if (user_input == '5')
        {
            printf("User entered 5!!!!!\n");
        }

        loop_counter++;
    }
}

int FunctionFoo(void)
{
    printf("Hello\n\n");
    int abc = 5;

    return abc;
}

int UpdateWeatherStation(void)
{
    printf("Updating Weather Station\n\n");
    int foo = 5;
    return foo;    
}