Código:
/home/ubuntu/: In function ‘main’:
/home/ubuntu/: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = unidad % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
centena = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena= decena % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = num % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena = num % 10;
^
/home/ubuntu/: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = unidad % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
centena = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena = num % 100;
^
/home/ubuntu/workspace: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena= decena % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
unidad = num % 10;
^
/home/ubuntu/workspace/: error: invalid operands to binary % (have ‘float’ and ‘int’)
decena = num % 10;
^
El programa es el siguiente:
//Programa para ingresar un numero (ENTERO Y POSITIVO) de 3 o 2 digitos y mostrarlo invertido.
Código
#include <stdio.h> int main (void) { float num=0; float unidad=0; float decena=0; float centena=0; float auxiliar=0; float numero_invertido=0; if ((num>99) && (num<1000)) { unidad = num % 100; unidad = unidad % 10; unidad = unidad * 100; centena = num % 100; centena = num - centena; centena = centena / 100; decena = num % 100; auxiliar = decena; decena= decena % 10; decena = auxiliar - decena; numero_invertido = unidad + decena + centena; } if ((num>9) && (num<100)) { unidad = num % 10; unidad = unidad * 10; decena = num % 10; decena = num - decena; decena = decena / 10; numero_invertido = unidad + decena; } else { } return 0; }
· Los códigos deben ir en etiquetas GeSHi
>aquí las reglas del foro
-Engel Lex