Thread: printf int

  1. #1
    Registered User
    Join Date
    Jan 2021
    Posts
    30

    printf int

    basically im starting from the beginning like everyone said to do.

    im struggling on how to printf a variable

    Code:
    #include <stdio.h>
    
    
    int main() {
       /* my first program in C */
       printf("Hello, World! \n");
       printf("hello world 2 \n");
       int int1 = 1;
       int int2 = 2;
       int int3 = (int1 + int2);
       
       printf("1+2= ", int3);
       
       return 0;
    }
    int3 is not being prtintf

    how do i get it to work
    Last edited by oods1; 01-23-2021 at 11:00 AM.

  2. #2
    Registered User
    Join Date
    Sep 2020
    Posts
    150
    You need a format specifier in your printf.
    Code:
    printf("1+2= %d", int3);

  3. #3
    Registered User
    Join Date
    Jan 2021
    Posts
    30
    Quote Originally Posted by thmm View Post
    You need a format specifier in your printf.
    Code:
    printf("1+2= %d", int3);
    thanks

    also where do i put the
    Code:
    \n
    to make a new line

    [edited[

    ive figured it out
    Last edited by oods1; 01-23-2021 at 11:17 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A way to printf out in printf?
    By 007fred50 in forum C Programming
    Replies: 4
    Last Post: 08-18-2019, 09:42 AM
  2. about printf
    By cheesestick in forum C Programming
    Replies: 9
    Last Post: 03-25-2005, 01:32 PM
  3. make printf using printf?
    By germaneater in forum C Programming
    Replies: 9
    Last Post: 11-10-2004, 10:58 PM
  4. printf
    By rage_i_am in forum C++ Programming
    Replies: 3
    Last Post: 07-28-2003, 05:21 PM
  5. Bad printf()!
    By kirby1024 in forum C Programming
    Replies: 2
    Last Post: 06-02-2002, 09:24 AM

Tags for this Thread