-->
Showing posts with label Program to input name. Show all posts
Showing posts with label Program to input name. Show all posts

Program to input name,address and roll number of some students using struct/ array of struct.

using codeblocks
---------------------------------------------------------------------------------------
// program to enter detail of some  students       //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[100]; //'access' is a variable to access members. This can hold maximum 100 members.it is called array of struct.
int main()
{
   int n,i;                                         //variable declaration
   printf("enter total value of n\n");
   scanf("%d",&n);                                  //accepts total value
   for(i=0;i<n;i++)
   {                                                 //execution of loop with inputs
    puts("enter roll number \n");
   scanf("%d",&access[i].roll);                      //gets data in different member
   puts("enter name \n");
   scanf("%s",access[i].name);
   puts("enter address \n");
   scanf("%s",access[i].address);

   }
   printf("entered data are\n");                  //loop execution to display data
   for(i=0;i<n;i++)
   {
    printf("roll is\n");
   printf("%d",access[i].roll);
   printf("name is\n");
   puts(access[i].name);                            //prints data from related member
   printf("address is\n");
   puts(access[i].address);                         //prints output from related member

    }
    return 0;
}
-----------------------------------------------------------------------------------------------------
using turbo c++
-------------------------------------------------------------------------------------------------
// program to enter detail of some  students       //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[100]; //'access' is a variable to access members. This can hold maximum 100 members.it is called array of struct.
int main()
{
   int n,i;                                         //variable declaration
   printf("enter total value of n\n");
   scanf("%d",&n);                                  //accepts total value
   for(i=0;i<n;i++)
   {                                                 //execution of loop with inputs
    puts("enter roll number \n");
   scanf("%d",&access[i].roll);                      //gets data in different member
   puts("enter name \n");
   scanf("%s",access[i].name);
   puts("enter address \n");
   scanf("%s",access[i].address);

   }
   printf("entered data are\n");                  //loop execution to display data
   for(i=0;i<n;i++)
   {
    printf("roll is\n");
   printf("%d",access[i].roll);
   printf("name is\n");
   puts(access[i].name);                            //prints data from related member
   printf("address is\n");
   puts(access[i].address);                         //prints output from related member

    }
getch();
    return 0;
}

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;

}