首页 > 试题广场 >

改正下面程序(在C中表示除法)。 void main

[问答题]
改正下面程序(在C中/表示除法)。
void main (int) / this program is perfect /
{
cows, legs integer;
printf ("How many cow legs did you count?\n);
scanf ("%c", legs);
cows = legs / 4
printf ("That implies there are %f cows.\n", cows)
}

推荐
第0行:应该有#include<stdio.h>
第1行:使用/*和*/,或者使用//。
第3行:int cows, legs;
第4行:count?\n");
第5行:%d,而不是%c,用&legs代替legs。
第7行:%d,而不是%f。
添加一个return语句。
下面是一个正确的版本:
#include <stdio.h>
int main (void) /* this program is perfect */
{
int cows, legs;
printf ("How many cow legs did you count?\n");
scanf ("%d", &legs);
cows = legs / 4
printf ("That implies there are %d cows.\n", cows);
return 0;
}

发表于 2018-05-05 22:21:26 回复(0)
#include <stdio.h>
int main() /*this program is perfect */
{
int cows, legs;
printf ("How many cow legs did you count?\n");
scanf ("%d", &legs);
cows = legs / 4;
printf ("That implies there are % cows.\n", cows);
return 0;
}


编辑于 2020-02-11 11:53:21 回复(0)