This code produces - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

This code produces

Panasonic99Panasonic99 Posts: 140Member
include

void xxx( int*, int);
void main()
{
int x =4, y = 13;
xxx(&x, y);
printf("%d%d
", x, y);
}

void xxx(int* x, int y)
{
*x += 4;
y += 7;
printf("%d%d
", *x, y);
}


820
813

I cant understand why-

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    [b][red]This message was edited by stober at 2005-8-8 16:48:40[/red][/b][hr]
    : include
    :
    : void xxx( int*, int);
    : void main()
    : {
    : int x =4, y = 13;
    : xxx(&x, y);
    : printf("%d%d
    ", x, y);
    : }
    :
    : void xxx(int* x, int y)
    : {
    : *x += 4;
    : y += 7;
    : printf("%d%d
    ", *x, y);
    : }
    :
    :
    : 820
    : 813
    :
    : I cant understand why-
    :

    you need to separate the numbers with one or more spaces -- they are all run togethere.
    [code]
    : printf("%d %d
    ", *x, y);
    [/code]


  • pseudocoderpseudocoder Posts: 687Member ✭✭✭
    Look at your format specifiers in the printf statements

    %d%d will make two numbers appear as one, or if you don't know where the 8 came from, then read up on pointers a bit more.

    : include
    :
    : void xxx( int*, int);
    : void main()
    : {
    : int x =4, y = 13;
    : xxx(&x, y);
    : printf("%d%d
    ", x, y);
    : }
    :
    : void xxx(int* x, int y)
    : {
    : *x += 4;
    : y += 7;
    : printf("%d%d
    ", *x, y);
    : }
    :
    :
    : 820
    : 813
    :
    : I cant understand why-
    :
Sign In or Register to comment.