-1
Problems in C. This error is showing:
Variable-sized Object may not be initializad
What to do to fix this error? Since I have already initialized everything.
LINE 66, 67 and 68
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
#include <string.h>
void painelPerguntas();
double calculoQtIteracao(double raizA, double raizB, double testeParada);
double calculoC(double raizA, double raizB);
double calculoModuloAB(double raizA, double raizB);
double calculoFxF(double raizA, double resultC);
char verificacaoSinal(double resultFxF);
double trocaAB(double raizA, double raizB, double resultC, char verificacaoSinal);
int main(){
painelPerguntas();
}
void painelPerguntas(){
double raizA = 0, raizB = 0, testeParada = 0;
printf("RAIZ [a]: ");
scanf("%lf", &raizA);
fflush(stdin);
printf("RAIZ [B]: ");
scanf("%lf", &raizB);
fflush(stdin);
printf("PARADA: ");
scanf("%lf", &testeParada);
//CALCULO QUANTIDADE DE ITERAÇÕES
calculoQtIteracao(raizA, raizB, testeParada);
double qtIteracoes = calculoQtIteracao(raizA, raizB, testeParada);
int qtIteracao = qtIteracoes;
// CALCULA VALOR DE C
calculoC(raizA, raizB);
double resultC = calculoC(raizA, raizB);;
//CALCULA |A-B|
calculoModuloAB(raizA, raizB);
double resultAB = calculoModuloAB(raizA, raizB);
//CALCULA F(A).F(C)
calculoFxF(raizA, resultC);
double resultFxF = calculoFxF(raizA, resultC);
//RESULTADO DE SINAL
verificacaoSinal(resultFxF);
char resultSinal = verificacaoSinal(resultFxF);
/*
printf("\n N | A | B | C | |A-B| | F(A).F(C) | SINAL");
printf("\n %d | %lf | %lf | %lf | %lf | %lf | %c ", qtIteracao, raizA, raizB, resultC, resultAB, resultFxF, resultSinal);
*/
//TROCA A/B COM C
trocaAB(raizA, raizB, resultC, resultSinal);
double resultTrocaAB = trocaAB(raizA, raizB, resultC, resultSinal);
//EXIBIÇÃO DO RESULTADO
printf("\n N | A | B | C | |A-B| | F(A).F(C) | SINAL");
int cont = 0;
for(cont = 0; cont <= qtIteracao; cont++){
double vetorA[cont] = resultTrocaAB, vetorB[cont] = resultTrocaAB, vetorC[cont] = resultC, vetorAB[cont] = resultAB;
double vetorFxF[cont] = resultFxF;
char vetorSinal[cont] = resultSinal;
printf("\n%d", cont);
}
}
double calculoQtIteracao(double raizA, double raizB, double testeParada){
double calculo = (log10(raizB - raizA) - log10(testeParada)) / log10(2);
return round(calculo);
}
double calculoC(double raizA, double raizB){
double calculo = (raizA + raizB) / 2;
return calculo;
}
double calculoModuloAB(double raizA, double raizB){
double calculo = raizA - raizB;
if(calculo < 0){
calculo = calculo * -1;
return calculo;
}else {
return calculo;
}
}
double calculoFxF(double raizA, double resultC){
double calculoFA = (pow(raizA,3)) - 3*raizA - 1;
double calculoFC = (pow(resultC,3)) - 3*resultC - 1;
double calculoFAxFC = calculoFA * calculoFC;
return calculoFAxFC;
}
char verificacaoSinal(double resultFxF){
if(resultFxF < 0){
char sinalNegativo = '-';
return sinalNegativo;
}else{
char sinalPositivo = '+';
return sinalPositivo;
}
}
double trocaAB(double raizA, double raizB, double resultC, char verificacaoSinal){
if(verificacaoSinal == '+'){
raizA = resultC;
return raizA;
}else{
return raizA;
}
if(verificacaoSinal == '-'){
raizB = resultC;
return raizB;
}else{
return raizB;
}
}
Which are Lines 66, 67 and 68?
– Maniero
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero