Float separation

On local content: write and run C programs
Machine on purpose: to master a simple C program editing, compiling, running and general process connection

My program:

#include<stdio.h>
int main()
{
    float a;
    scanf("%f",&a);
    printf("%d %d",a*1000/1000,(a-a*1000/1000)*1000);
    return 0;
}
  • Program copyright and version declarations section:
  • Copyright © 2020, Computer Science, Yantai University
  • All rights reserved.
  • File name: Test .c
  • Author: Lee invented
  • Completion Date: February 3 2020
  • Version: v1.0
  • Description of some task and its solution: Data type conversion
  • Input Description: 123.456
  • Description of the problem: to write a program, whose function is to: a floating-point input from the keyboard (with three digits after the decimal point), and then outputs the integer and fractional part of the number.
  • Program Output: 123 456
  • Analysis: using the data type conversion and basic algorithms
  • Algorithm design: the use of four arithmetic formulas derived

operation result:
Here Insert Picture Description

Experiences:
the basis of the need for timely to consolidate

Knowledge Summary:
pay attention to the type of variables involved in the operation and use of reasonable algorithms.

Published 10 original articles · won praise 0 · Views 184

Guess you like

Origin blog.csdn.net/koaci/article/details/104157510