[c] How can you print multiple variables inside a string using printf?

I want to find the maximum value of two numbers, and print it. I want to print all three numbers. I am using the following code.

#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();

}

However, I receive two syntax errors (Please find the attached figure). Could anybody help me out with it?

This question is related to c printf syntax-error

The answer is


Change the line where you print the output to:

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

See the docs here


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

Examples related to c

conflicting types for 'outchar' Can't compile C program on a Mac after upgrade to Mojave Program to find largest and second largest number in array Prime numbers between 1 to 100 in C Programming Language In c, in bool, true == 1 and false == 0? How I can print to stderr in C? Visual Studio Code includePath "error: assignment to expression with array type error" when I assign a struct field (C) Compiling an application for use in highly radioactive environments How can you print multiple variables inside a string using printf?

Examples related to printf

How I can print to stderr in C? How can you print multiple variables inside a string using printf? Unsigned values in C How to print multiple variable lines in Java Scanf/Printf double variable C Format specifier %02x %i or %d to print integer in C using printf()? What is the printf format specifier for bool? printf() prints whole array Printf width specifier to maintain precision of floating-point value

Examples related to syntax-error

Uncaught SyntaxError: Unexpected token u in JSON at position 0 How to solve SyntaxError on autogenerated manage.py? Checking whether the pip is installed? (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape How can you print multiple variables inside a string using printf? Unexpected token < in first line of HTML Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL 'Syntax Error: invalid syntax' for no apparent reason How can I fix MySQL error #1064? Notice: Trying to get property of non-object error