Not getting expected output of printf

#include<stdio.h>
int main()
{
printf(“I am learning the %c programming language \n”, ‘C’);
printf(“I will just complete Chapter %d \n”,‘10’);
printf(“However only %f percent is ready to move on\n”,‘99.9’);
return 0;

}

OUTPUT:

I am learning the C programming language
I will just complete Chapter 12592
However only 0.000000 percent is ready to move on

note:

I was supposed to get 10 instead of 12592
Also not printing 99.9 percent, getting zeroes

Compiler: gcc -v

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1

Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix

Your 3rd printf line is using a %f format, but you give it a string with ‘99.9’. Either change the format to %s or change the string to the number 99.9. Also, do this to you code:

[code]
// code here
[/code]

That’ll make it look perty.

1 Like

Hey hey, did you figure this out? Do you still need help?

Yes Sir. Thanks for your help and prompt response.

1 Like