C语言 如何使用printf打印字符串中的多个变量?

bqjvbblv  于 2023-10-16  发布在  其他
关注(0)|答案(2)|浏览(174)

我想找出两个数的最大值,并打印出来。我想把这三个数字都打印出来。我使用以下代码。

#include<stdio.h>
#include<conio.h>
main()
{
     //clrscr();
     int a,b,c;
     printf("insert two numbers:");
     scanf("%d%d", &a, &b);
     c = (a>b) ? a : b;
     printf("\nmaximum of %d",a," and %d",b,"  is = %d" c);
     getch();

}

然而,我收到两个语法错误(请找到附图)。有人能帮我吗?

juud5qan

juud5qan1#

将打印输出的行更改为:

printf("\nmaximum of %d and %d is = %d",a,b,c);

参见文档here

zujrkrfu

zujrkrfu2#

printf("\nmaximum of %d and %d is = %d",a,b,c);

相关问题