C

Saturday, 8 July 2017

Program to demonstrate pointer to structure

#include<stdio.h>
main()
{
          struct student
          {
                   int roll;
                   char name[20];
                   int age;
                   char class[8];
          };        
          struct student s,*ptr;
          ptr=&s;
          printf("Enter the student record\n");
          printf("Roll no. :");
          scanf("%d",&ptr->roll);
          printf("Name :");
          scanf("%s",&ptr->name);
          printf("Age:");
          scanf("%d",&ptr->age);
          printf("Class :");
          scanf("%s",&ptr->class);
          printf("\n Record details are\n");
          printf("Roll no: %d\n",ptr->roll);
          printf("Name: %s\n",ptr->name);
          printf("Age: %d\n",ptr->age);
          printf("Class : %s\n",ptr->class);

}

No comments:

Post a Comment

Write a program to draw a circle using mid-point circle drawing algorithm.

#include<iostream.h> #include<graphics.h> #include<conio.h> void drawcircle(int x0, int y0, int r) {         ...