how here j is printing 7.give the explanation

This is a discussion on how here j is printing 7.give the explanation within the C Programming forums, part of the General Programming Boards category; Code: #include<stdio.h> main() { int i = 3,j; j = add(++i); printf("i = %d j = %d\n", i, j); } ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    8

    how here j is printing 7.give the explanation

    Code:
    #include<stdio.h>
    main()
    {
    int i = 3,j;
    j = add(++i);
    printf("i = %d j = %d\n", i, j);
    }
    
    add(ii)
    int ii;
    {
    ii++;
    printf("ii = %d\n", ii);
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,980
    No cookie for you until you tell us where you got this from and why you want to know the answer when you have not made any effort to figure it out yourself.

    If you are getting this from some book, then throw the book away (or return it to the library). If you are getting this from some website, then close any browser windows/tabs that has that website opened, remove it from your bookmarks, and clear your history and cache. Then forget about that website. If you wrote the program yourself... you need to unlearn what you have learned.
    Last edited by laserlight; 09-03-2010 at 05:15 AM.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    230
    i suggest that if you are using a book/Internet, take a paper and write down the code...then slowly line after line you should be able to understand this...it is boring...but it is a method!

  4. #4
    C lover
    Join Date
    Oct 2007
    Location
    Virginia
    Posts
    265
    THAT code is old!

    Code:
    add(ii)int ii;

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    what is the program output please explain
    Continuing with the homework dump and 0% effort I see.

    Soon, I will lock them on sight.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. Printing Lines to .txt File
    By Programmer3922 in forum C Programming
    Replies: 2
    Last Post: 08-02-2008, 12:45 PM
  3. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  4. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 07:10 PM
  5. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 03:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21