1,075,752 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by phani1092 which have been Voted Down

Try compiling the above code in

www.codepad.org

phani1092
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
#include <stdio.h>

int main(void)
{
    int arr[2][2][2]={1,2,3,4,5,6,7,8};
    int *p = arr;

    printf("%d", *p);

    return 0;
}

Try compiling this you will get what i am talking about. 
phani1092
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

you all are making things complex. Here's the simplest way of doing

int num;
printf("enter any five digit num \n");
scanf("%d",&num);
len=findoutlength(num);
while(len>0)
{
  d=num%10;
  if(d==0)
  {
  printf("digit %d is 0",d);
  }
  else if(d%2==0)
  {
  printf("digit %d is even",d);
  }
  else
  {
  printf("digit %d is odd",d);
  }
  len--;
}  

I guess this will give you the desired output.

phani1092
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

Now deceptikon, nitin1 asked about the first element of the array and for first element there is no need to type cast,if it would have been necessary the compiler would have thrown definite error.

phani1092
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

In array pointers, when you are not specifying any index of the array it takes the first position as default. Unless untill you give specific index to the array,it returns the value of first index pointer. You would get the same output if you typecast or not.

In array pointers, when you are not specifying any index of the array it takes the first position as default. Unless untill you give specific index to the array,it returns the value of first index p

.

phani1092
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.0457 seconds using 2.47MB