C++

Ive got these two questions on my homework and i can't figure out what they are supposed to print any help would appreciated.
(1)
int num[]={1,2,3,4,5,6,7,8,9}, *pnum=&num[2];
pnum++;
++pnum;
printf("%d\n",*pnum);

(2)
int num[9]={1,2,3,4,5,6,7,8,9}, *p;
p=num;
*(p+1)=0;
printf("%d,%d,%d\n", *p, p[1], (*p)++);
Compile and run the code to find out.

1
2
3
4
5
6
7
8
#include <cstdio>
int main()
{
    int num[]={1,2,3,4,5,6,7,8,9}, *pnum=&num[2];
    pnum++;
    ++pnum;
    printf("%d\n",*pnum);
}


1
2
3
4
5
6
7
8
#include <cstdio>
int main()
{
    int num[9]={1,2,3,4,5,6,7,8,9}, *p;
    p=num;
    *(p+1)=0;
    printf("%d,%d,%d\n", *p, p[1], (*p)++); 
}


Edit: Just click the little gear to call the on-line compiler to compile and run each program.
Last edited on
Topic archived. No new replies allowed.