我在学校c编程学习,我有这个任务,在这段代码中找到3个错误。我找不到任何东西!这一切似乎都很好...... 也许我还应该提一下,我已经学习了大约两个月。
这是代码:
#include <stdio.h>
#include <stdlib.h>
#define LOWER 0
#define UPPER 172486
/*
Bug Report:
1.
2.
3.
*/
void welcome(void);
void useage(void);
void getNumber(void);
void printTwice(int number);
int main(void)
{
welcome();
return 0;
}
/*
This function prints "welcome".
input: none
output: none
*/
void welcome(void)
{
printf("Welcome to my cool program!\n");
useage();
}
/*
This function prints what the program is for.
input: none
output: none
*/
void useage(void)
{
printf("My program gets a number from you - and prints it twice in a row!\n");
getNumber();
}
/*
The function gets a number.
input: none
output: none
*/
void getNumber(void)
{
printf("Please enter a number between 0 - 172,486: \n");
int number = 0;
scanf("%d", &number);
while(number < LOWER || number > UPPER)
{
printf("Invalid choice!\n");
scanf("%d", &number);
}
printTwice(number);
}
/*
Prints the number twice.
input: the number we got from the user.
output: none
*/
void printTwice(int number)
{
printf("The number twice in a row: %d%d", number, number);
}
答案 0 :(得分:0)
的问题:
1
没有警告输入字符串而不是数字。 00将被打印。
2
printf("The number twice in a row: %d%d", number, number);
数字之间没有空格,没有行终止 拟议的变更:
printf("The number twice in a row: %d %d\n", number, number);