<ex1>
#include <stdio.h>
int main(void)
{
int arr[5]={1,2,3,4,5};
int *ptr = arr;
int i;
for(i=0; i<5; i++)
*(ptr+i) += 2;
for(i=0; i<5; i++)
printf("\n%d", arr[i]);
return 0;
}
<no2>
<ex1>
#include <stdio.h>
int main(void)
{
int arr[5]={1,2,3,4,5};
int *ptr = arr;
int i;
for(i=0; i<5; i++)
*(ptr+i) += 2;
printf("\n%d", arr[i]);
return 0;
}
What is diffenrent between no1 and no2?
in the 2nd one the "printf("\n%d", arr[i]);" is not part of a for loop
since there are no "{" ,"}" only the first command is part of the for loop