Trying to print integers and text using prinf in java

You’re completely missing the point of String.format. The point of it is to avoid manually formatting and concatenating strings representing elements, which you are doing anyway. Since if (num1 == 24 && num2 == 00) must be true to be in that if block you can simply System.out.println(“24 00 Midnight”);.

decimal of numbers in c

The error is that %d in the format specifier of both scanf and printf represents decimal, so it expects an int (in the case of scanf, a pointer to int) Since you are declaring b and c as float, %d in the lines scanf(“%d”,&b); printf(“%d lbs is %d kgs.”,b,c); should be changed to %f respectively. … Read more

Please explain the difference in the printfs below

%x format specifier experts the argument to be of type unsigned int. In your case, printf(“%x\n”,(const uint8_t)0x0D); printf(“%x\n”,0x0D); arguments will be promoted (default promotion rule) to match the type, but in case of printf(“%x\n”,(const uint8_t *)0x0D); //supplying a pointer printf(“%x\n”,(uint8_t *)0x0D); //supplying a pointer You’ll invoke undefined behavior, as per C11, chapter ยง7.21.6.1 […] If … Read more

Function does not return printf

void correct(r) is declaration and it means – correct is a function that takes r type in arguments and returns void. Just remove void to call function. correct(r). And you need to change chars to char * or const char*. const char *c1 = “Cristoforo”; const char *c2 = “cristoforo”; const char *c3 = “CRISTOFORO”;

A beginner questions about printf, java

Actually printf is used in java if you are using formatting as he was asking about in his question. double number = 10.5555555; System.out.printf(“The number 10.555555 rounded to two decimal places is %2f”, number); Now as far as the symbols, the ones I know are %d = integer, %f= double, %s= string.