Advertisement
thenewboston

C Programming Tutorial - 6 - Conversion Characters

Aug 22nd, 2014
1,174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     // If you want to use strings, use %s
  7.     // Good for programs where users can enter their name
  8.     printf("%s is the best person ever\n", "Bucky");
  9.  
  10.     // Use %d for integers
  11.     printf("I ate %d corndogs at the fair\n", 9);
  12.  
  13.     // %f for numbers with decimal places (floating point values)
  14.     // 6 decimal places by default
  15.     printf("Pi is %f \n", 3.1415926535);
  16.     printf("Pi is %.1f \n", 3.1415926535);
  17.     printf("Pi is %.3f \n", 3.1415926535);
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement