Friday, 15 April 2016

C Program to Store Student Information Using Structures And Pointer

Problem:- Write A C Program to Store Information Using Structures With Pointer With Dynamically Memory Allocation In Structure In C or c program to store information of 10 students using structure or c program to store information using structures with dynamic memory allocation or dynamic memory allocation for structures in c or dynamic memory allocation in c programming examples or c program using structures employee details or dynamic memory allocation for array of structures in c or memory allocation for structure members in c or c program examples using structures.

What Is Pointer?.

The pointer is a variable which holds the address of another variable. If you want to practice more on pointer question Click here.

Defining a structure

struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.

Syntax :

struct structure_name
{
//Statements
};

Solution:-

#include <stdio.h>
#include<stdlib.h>
struct name {
   int a;
   char c[30];
};
int main(){
   struct name *ptr;
   int i,n;
   printf("Enter The No. : ");
   scanf("%d",&n);

/* Allocates the memory for n structures with pointer ptr pointing to the base address. */
   ptr=(struct name*)malloc(n*sizeof(struct name));
   for(i=0;i<n;++i){
       printf("Enter string and integer respectively:\n");
       scanf("%s%d",&(ptr+i)->c, &(ptr+i)->a);
   }
   printf("Displaying Infromation:\n");
   for(i=0;i<n;++i)
       printf("%s\t%d\t\n",(ptr+i)->c,(ptr+i)->a);
   return 0;

}

Output:-


C Program to Store Student Information Using Structures And Pointer


You May Also Like


1. C Program To Insert An Element Desired or Specific Position In An Array

2. C Program For Remove Duplicates Items In An Array

3. C Program To Delete Element From Array At Desired Or Specific Position

4. C Program For Print "I AM IDIOT" Instead Of Your Name Using Array

5. C Program For Check String Is Palindrome Or Not Using For Loop

6. C Program For Convert All Input String Simultaneously Into Asterisk ( * )

7. C Program For Calculator Using Switch Case

8. C Program For Find A Grade Of Given Marks Using Switch Case

9. C Program For Finding Radius Circumference Using Switch Case

10. C Program For Remove All Vowels From A String Using Switch Case



Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment