Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4241042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:14:59+00:00 2026-05-21T03:14:59+00:00

The output of following program #include<stdio.h> int main(){ int *p[10]; printf(%ld %ld\n,sizeof(*p),sizeof(p)); } is

  • 0

The output of following program

#include<stdio.h>
int main(){
    int *p[10];
    printf("%ld %ld\n",sizeof(*p),sizeof(p));
}

is

8   <--- sizeof(*p) gives  size of single element in the array of int *p[10] 
80  <--- sizeof(p) gives  size of whole array which is 10 * 8 in size.

now see the following program

 #include<stdio.h>
 #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
 int array[] = {23,34,12,17,204,99,16};

  int main()
  {
      int d;
      printf("sizeof(array) = %ld \n",sizeof(array));
      printf("sizeof(array[0]) = %ld \n",sizeof(array[0]));
      printf("sizeof int %ld\n",sizeof(int));
      printf("TOTAL_ELEMENTS=%ld \n",TOTAL_ELEMENTS);
      for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
          printf("%d\n",array[d+1]);

      return 0;
  }

is

sizeof(array) = 28 
sizeof(array[0]) = 4  <--here
sizeof int 4
TOTAL_ELEMENTS=7 

What I am not able to understand is why is the sizeof(array[0]) different in both the outputs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:15:00+00:00Added an answer on May 21, 2026 at 3:15 am

    int *p[10];
    is an array of pointers.

    *p
    is the first element of that array of pointers. So it is a pointer to an integer. It is not an integer.

    int array[] = {23,34,12,17,204,99,16}; is an array of integers. So array[0] is the first element of that array. So it is an integer.

    The size of a pointer to an integer (*p) and an integer (array[0]) are different.

    So sizeof(*p) and sizeof(array[0])
    are different.

    sizeof(p) gives the size of the array of pointers. So it is: 10 x 8 = 80.
    i.e. (number of elements) x (size of one element)

    sizeof(array) gives the size of the array of integers. So it is: 7 x 4 = 28.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));
I wrote the following program: #include<stdio.h> int main(void) { float f; printf(\nInput a floating-point
I wrote following program #include<stdio.h> main () { extern int i; printf(\n%d,i); } int
What's the output of the following program and why? #include <stdio.h> int main() {
The following program yields 12480 as the output. #include<stdio.h> int main() { char c=48;
I have the following C program: #include <fcntl.h> #include <termios.h> #include <stdio.h> int main()
I have the following program #include <stdio.h> int main(void) { unsigned short int length
Possible Duplicate: Size of character ('a') in C/C++ The following program #include <stdio.h> int
I have the following C program: #include <stdio.h> int main() { double x=0; double
i wrote the following program #include <stdio.h> main() { int i = 2; float

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.