Other format specifiers In C Language

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

In addition to %d and %u for integers, here are some other commonly used format specifiers in C:

  • %f : for floating-point numbers.
  • %c : for characters.
  • %s : for strings.
  • %x or %X : for hexadecimal integers (lowercase or uppercase).
  • %o : for octal integers.
  • %p : for pointers.
  • %% : for printing a literal % character.
  • %e or %E : for scientific notation of floating-point numbers.
  • %g or %G : for either %f or %e whichever is shorter.
  • %ld, %lld, %Lf etc : for long and long long data types.

For example, the following code would print a floating-point number and a string:

Copy code

float pi = 3.14159; char name[] = "John Doe"; printf("Pi is approximately %f and my name is %s", pi, name);

This will output:

Copy code

Pi is approximately 3.14159 and my name is John Doe

Note that, depending on the system you are using, there may be variations in the format specifiers for different types of data.

3. Input Output In C

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?