各位大神,求教一道c语言题目,谢谢了
指出下面语句中的错误,并纠正这些错误(注意:每个语句中的错误可能不止一个),写在一个程序中,用注释语句写出原语句,程序中写出修改后的语句(注意:变量的定义):a)scan...
指出下面语句中的错误,并纠正这些错误(注意:每个语句中的错误可能不止一个),写在一个程序中,用注释语句写出原语句,程序中写出修改后的语句(注意:变量的定义):
a) scanf( “d”, value );
b) printf( “The product of %d and %d id %d”\n, x, y);
c) firstNumber secondNumber = sumOfNumbers
d) if( number=>largest )
largest == number;
e) */ Program to determine the largest of three integers /*
f) Scanf( “%d” , anInteger );
g) Printf( “Remainder of %d devided by %d is \n”, x, y, x%y );
h) If ( x=y); // (判断相等)
Printf( %d is equal to %d\n”, x, y, );
i) Printf( “The sum is %d\n,” x y);
j) printf( “The value you entered is: %d\n, &value ); 展开
a) scanf( “d”, value );
b) printf( “The product of %d and %d id %d”\n, x, y);
c) firstNumber secondNumber = sumOfNumbers
d) if( number=>largest )
largest == number;
e) */ Program to determine the largest of three integers /*
f) Scanf( “%d” , anInteger );
g) Printf( “Remainder of %d devided by %d is \n”, x, y, x%y );
h) If ( x=y); // (判断相等)
Printf( %d is equal to %d\n”, x, y, );
i) Printf( “The sum is %d\n,” x y);
j) printf( “The value you entered is: %d\n, &value ); 展开
1个回答
展开全部
#include<stdio.h>
#include<math.h>
int main(){
/*
a) scanf( “d”, value );
*/
int value = 0;
scanf("%d", &value);
/*
b) printf( “The product of %d and %d id %d”\n, x, y);
*/
int x = 2, y = 3;
printf("The product of %d and %d is %d\n", x, y, x * y);
/*
c) firstNumber secondNumber = sumOfNumbers
*/
int firstNumber = 10, secondNumber = 20;
int sumOfNumbers = firstNumber + secondNumber;
/*
d) if( number=>largest )
largest == number;
*/
int number = 10, largest = 100;
if (number >= largest) {
largest = number;
}
/*
e) Program to determine the largest of three integers
*/
int first = 10, second = 20, third = 6;
int largestOfAll = first;
if (largestOfAll < second) {
largestOfAll = second;
}
if (largestOfAll < third) {
largestOfAll = third;
}
/*
f) Scanf( “%d” , anInteger );
*/
int anInteger;
scanf("%d", &anInteger);
/*
g) Printf( “Remainder of %d devided by %d is \n”, x, y, x%y );
*/
printf("Remainder of %d devided by %d is %d\n", x, y, x%y);
/*
If ( x=y); // (判断相等)
Printf( %d is equal to %d\n”, x, y, );
*/
if (x == y); // (判断相等)
printf("%d is equal to %d\n", x, y);
/*
i) Printf( “The sum is %d\n,” x y);
*/
printf( "The sum is %d\n", x, y);
/*
j) printf( “The value you entered is: %d\n, &value );
*/
printf( "The value you entered is: %d\n", value );
return 0;
}
总结一下上面代码段存在的问题:scanf传递的应该是变量的地址,printf打印的是变量,scanf和printf前面的格式化字符串都应该用英文引号而不是中文,printf格式化字符串里的占位符数量和格式化字符串后面的参数个数相同,否则会出现错误。C语言的所有标点符号都是英文的。判断相等用两个等于号==,赋值操作左边的是要被赋值的变量,右边是计算的结果。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |