4
Write a C program to validate a batch of checks. The program should initially request the sum of the batch and the number of checks. Next you should read the value of each check by calculating the total sum. After typing all checks the program must print the following messages: LOT Ok if the sum given is equal to the calculated sum.Negative difference if the calculated sum is less than that reported. Positive difference if the calculated sum is greater than that reported. Note: The value of the difference must be printed (if any).
Follow the code done so far.
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
void main()
{
setlocale(LC_ALL, "Portuguese");
int somaLote, aux;
float somaCheques, somaTotal;
printf("Digite a quantidade de cheques: ");
scanf("%d", somaLote);
for(aux=0; aux<=somaLote; aux++)
{
printf("Insira o valor do cheque: ");
scanf("%f", &somaCheques);
somaTotal = somaTotal + somaCheques;
}
printf("Soma total dos cheques: %d", somaLote);
printf("Valor total dos cheques: %f", somaTotal);
}
Compiler crashes and keeps giving error.
I don’t think it’s right to give the answer to the algorithm, since it’s an exercise, where the purpose is to get it to train the language.
– Jonathan Barcela
The question begs this. And he didn’t order ready, he asked us to solve his logic problem. There are several errors in the code, solving one does not help anything.
– Maniero
Ms the rest is part of the question, not only this sentence. If you take to the letter only what is with question as question, then the answer is "Yes".
– Maniero
What was requested was the solution of the "compiler lock and keep giving error", what was generated by the scanf without the &, assemble all the logic and do the exercise I think runs a little. Whereas what was asked was that we "scan" the code behind the bug that causes the compiler to crash.
– Jonathan Barcela
Then he decides which answer is best for him.
– Maniero