我的程序在下面,這是爲了課程。 我的問題是我應該添加到我的程序,以停止或消除'。'小數點後 和零後打印我的答案。如何在'C'後小數點以後抑制或消除零點
// Ch5Pgm7.cpp : Takes a number entered by the user and cubes it.
//Written by: Chris Howard Sept. 25th 2014.
#include "stdafx.h"
#include "stdio.h"
void cube(double NUM); // My function that will cube the users input
int main(void)
{
double NUM;
printf("Please enter a number: ");
scanf_s("%lf", &NUM);
cube(NUM);
return 0;
}
void cube(double NUM)
{
NUM = NUM * NUM * NUM;
printf("%lf\n", NUM);
}
閱讀上printf的格式化字符串:http://linux.die.net/man/3/printf – datenwolf 2014-09-25 18:36:15
^^迄今爲止的最佳答案。 – 2014-09-25 18:38:25