Saturday 1 November 2014

23. Write a program with structure and pointer.

No comments :


23. Write a program with structure and pointer.






PRO-23:
#include<stdio.h>
#include<conio.h>
struct student
{              char name[20];
                int no;
                int age;
};
void main()
{              struct student s,*ptr;
                ptr=&s;
                clrscr();
                printf("\nEnter INPUT");
                printf("\n-----------");
                printf("\nEnter Student Name :");
                scanf("%s",ptr->name);
                printf("\nEnter Student Rollno. :");
                scanf("%d",&ptr->no);
                printf("\nEnter student Age :");
                scanf("%d",&ptr->age);
                printf("\n:: OUTPUT of Student details is :: ");
                printf("\n------------------------------");
printf("\n  Name       : %s",ptr->name);
                printf("\n  Roll No.is : %d",ptr->no);

printf("\n  Age is     : %d",ptr->age);
                getch();   }
OUTPUT:
Enter INPUT
-----------
Enter Student Name :AJAY
Enter Student Rollno. :1
Enter student Age :25
:: OUTPUT of Student details is ::
------------------------------
  Name       : AJAY
  Roll No.is : 1
  Age is     : 25

No comments :

Post a Comment