0% found this document useful (0 votes)
7 views2 pages

Array Pointer Structure

Uploaded by

mfisurveyors
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Array Pointer Structure

Uploaded by

mfisurveyors
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Array

#include<stdio.h>

int main()
{
int a[5]={1,2,3,4,5};
int i=0;

i=0;
for(i=0;i<5;i++)
{
printf("Value: %d \n",a[i]);
}

return 0;
}

Pointer

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

int main()
{
int a = 5;
int *b;
b = &a;

printf("Value of a = %d\n", a);


printf("Value of a = %d\n", *(&a));
printf("Value of a = %d\n", *b);

printf("Address of a = %u\n", &a);


printf("Address of a = %u\n", b);
printf("Address of b = %u\n", &b);
printf("Value of b = address of a = %u", b);

return 0;
}
Structure

#include<stdio.h>

int main()
{
struct student {
int rollno;
char name[25];
float percent;
};

struct student s1, s2;

printf ("\nEnter roll no, names and percentage of 1st


student:\n");
scanf ("%d %s %f", &[Link], &[Link], &[Link]);

printf ("\nEnter roll no, names and percentage of 2nd


student:\n");
scanf ("%d %s %f", &[Link], &[Link], &[Link]);

printf ("\nDispalying student information");


printf ("\n%d, %s, %f", [Link], [Link], [Link]);
printf ("\n%d, %s, %f", [Link], [Link], [Link]);

return 0;
}

You might also like