lidi_si Posted November 22, 2009 at 04:51 PM Report Share #297197 Posted November 22, 2009 at 04:51 PM Daee galera! acabei de fzr um código em c..mas to com duvida no termino da resoluçao dele.. nao to conseguind achar parte fracionaria e arredondamento; aeww vai #include<stdio.h>: #include<stdlib.h> main(){ int num; float resposta; printf("Entre com numero real:"); scanf("%d",&num); resposta=(float)num-resposta; printf("%2.0f",resposta); system("PAUSE");} Link to comment Share on other sites More sharing options...
lidi_si Posted November 22, 2009 at 04:54 PM Author Report Share #297198 Posted November 22, 2009 at 04:54 PM resposta=equivale achar parte inteira do numero Link to comment Share on other sites More sharing options...
Baderous Posted November 22, 2009 at 05:32 PM Report Share #297203 Posted November 22, 2009 at 05:32 PM Há aí algo que não está bem. A variável 'resposta' não contém nenhum valor por ti atribuído. E estás a pedir um número real, mas de seguida usas o scanf com o %d, o que quer dizer que na verdade vais ler um inteiro. Link to comment Share on other sites More sharing options...
lidi_si Posted November 22, 2009 at 06:03 PM Author Report Share #297213 Posted November 22, 2009 at 06:03 PM #include<stdio.h> #include<stdlib.h> main(){ float numero; int parte_inteira; printf("Entre com um numero real com parte fracionaria:"); scanf("%f",&numero); parte_inteira=(float)numero-parte_inteira; printf("%d",parte_inteira); system("PAUSE");} Link to comment Share on other sites More sharing options...
vasco16 Posted November 22, 2009 at 08:41 PM Report Share #297226 Posted November 22, 2009 at 08:41 PM #include<stdio.h> #include<stdlib.h> main(){ float numero; int parte_inteira; printf("Entre com um numero real com parte fracionaria:"); scanf("%f",&numero); parte_inteira=(float)numero-parte_inteira; printf("%d",parte_inteira); system("PAUSE");} Qual é a duvida? Parece-me c++ e acho que te vai devolver o resto da divisao.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now