Well,
First of all, I'm a newbie user.
I need your help!!!
I use a Borland C++ compiler version 3.0. So the range of the unsigned int data type is from 0 up to 65,000. Well,
I tried store the value 40,030 into an variable that it used this data type but, when I runned the program I received the following value: -25,216.
What's happened??
See the source code below:
#include <stdio.h>
#include <conio.h>
unsigned int fatorial(int N);
void main(void)
{
int ValInt;
unsigned int ProdFator;
clrscr();
printf("Calcule fatorial de "
scanf("%d",&ValInt);
ProdFator = fatorial(ValInt);
printf("%d! ‚ igual a %d", ValInt, ProdFator);
}
unsigned int fatorial(int N)
{
int contador;
unsigned int ValFator = 1;
for(contador = 1; contador <= N; ++contador) ValFator = contador * ValFator;
return(ValFator);
}
First of all, I'm a newbie user.
I need your help!!!
I use a Borland C++ compiler version 3.0. So the range of the unsigned int data type is from 0 up to 65,000. Well,
I tried store the value 40,030 into an variable that it used this data type but, when I runned the program I received the following value: -25,216.
What's happened??
See the source code below:
#include <stdio.h>
#include <conio.h>
unsigned int fatorial(int N);
void main(void)
{
int ValInt;
unsigned int ProdFator;
clrscr();
printf("Calcule fatorial de "
scanf("%d",&ValInt);
ProdFator = fatorial(ValInt);
printf("%d! ‚ igual a %d", ValInt, ProdFator);
}
unsigned int fatorial(int N)
{
int contador;
unsigned int ValFator = 1;
for(contador = 1; contador <= N; ++contador) ValFator = contador * ValFator;
return(ValFator);
}