CyberWizard
- Sep 17, 2014
- 15
- Joined
- Sep 17, 2014
- Messages
- 15
I though i could help my younger sister with some homework, boy was i wrong...
The code was supose to accept 2 integer and print the sum of all integers beetween them.
Ex: 5 - 7 = 5+6+7 = 18
Instead it just runs endsly
#include <stdio.h>
#include <locale.h>
int fSoma(int valor1, int valor2)
{
int aux; // Variavel auxiliar
int c; // Contador
c=0;
aux=0;
for(c=valor1;c=valor2;c++ )
{
aux=aux + c;
printf("\n A somar %i a %i",c,aux);
}
return(aux);
}
void main()
{
int a;
int b;
int result;
setlocale(LC_ALL,"Portuguese"); /* Activa o teclado português */
printf("\n Qual o numero mais baixo ?");
scanf("%i",&a);
printf("\n O numero %i foi selecionado",a);
printf("\n\n Qual o numero mais alto ?");
scanf("%i",&b);
printf("\n O numero %i foi selecionado",b);
result=fSoma(a,b);
printf("O somatório é:%i",result);
}
What wrong here? Can some1 help me out ?
The code was supose to accept 2 integer and print the sum of all integers beetween them.
Ex: 5 - 7 = 5+6+7 = 18
Instead it just runs endsly
#include <stdio.h>
#include <locale.h>
int fSoma(int valor1, int valor2)
{
int aux; // Variavel auxiliar
int c; // Contador
c=0;
aux=0;
for(c=valor1;c=valor2;c++ )
{
aux=aux + c;
printf("\n A somar %i a %i",c,aux);
}
return(aux);
}
void main()
{
int a;
int b;
int result;
setlocale(LC_ALL,"Portuguese"); /* Activa o teclado português */
printf("\n Qual o numero mais baixo ?");
scanf("%i",&a);
printf("\n O numero %i foi selecionado",a);
printf("\n\n Qual o numero mais alto ?");
scanf("%i",&b);
printf("\n O numero %i foi selecionado",b);
result=fSoma(a,b);
printf("O somatório é:%i",result);
}
What wrong here? Can some1 help me out ?