-->

Program to input name,address and roll of a student and display that using struct.

using codeblocks
-----------------------------------------------------------------------
Program to input name,address and roll of a student and display that using struct.
----------------------------
// program to enter detail of a  student            //comment abt. program
#include <stdio.h>                                 //header file
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct

}access; //'access' is a variable to access members.
int main()
{

   puts("enter name \n");
   gets(access.name);                             //accessing member with period operator for input
   puts("enter address \n");
   gets(access.address);                          //accessing member with period operator for input
   puts("enter roll number \n");
   scanf("%d",&access.roll);                     //accessing member with period operator for input
   printf("name is\n");
   puts(access.name);                            //for output
   printf("address is\n");
   puts(access.address);                         //for output
   printf("roll is\n");
   printf("%d",access.roll);                   //for output
    return 0;

}
-----------------------------------------------------------------------------------------------------------------------
using turboc++
----------------------------------------------------------------------------------------
// program to enter detail of a  student            //comment abt. program
#include <stdio.h>                                 //header file
#include<conio.h>
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct

}access; //'access' is a variable to access members.
int main()
{

   puts("enter name \n");
   gets(access.name);                             //accessing member with period operator for input
   puts("enter address \n");
   gets(access.address);                          //accessing member with period operator for input
   puts("enter roll number \n");
   scanf("%d",&access.roll);                     //accessing member with period operator for input
   printf("name is\n");
   puts(access.name);                            //for output
   printf("address is\n");
   puts(access.address);                         //for output
   printf("roll is\n");
   printf("%d",access.roll);                   //for output
   getch();
    return 0;

}


No comments:

Post a Comment