-->

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 know total memory occupied by struct using size of struct concept.

using codeblocks
--------------------------------------------------------------------------------------------------------------------------
Program to know total memory occupied by struct using size of struct concept.
----------------------------------------------------------------------------------------------------------
// program to use sizeof() in struct            //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

};
struct data access={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are data.
int main()
{

   printf("total memory is\n");
   printf("%d",sizeof(access));                  // display of total bytes used by struct, using access
    return 0;
}

---------------------------------------------------------------------------------------
using turbo c++
------------------------------------------------------------------------
// program to use sizeof() in struct            //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

};
struct data access={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are data.
int main()
{

   printf("total memory is\n");
   printf("%d",sizeof(access));                  // display of total bytes used by struct, using access
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;

}


program to initialize data with struct.

using codeblocks
----------------------------------------------------------------------------------------------------------------------
// program to initialize data in struct            //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={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are                                                              //data.

int main()
{

   puts("name is\n");
   puts(access.name);                             //accessing member with period operator
   puts("address is\n");
   puts(access.address);                          //accessing member with period operator
   puts("roll number is\n");
   printf("%d",access.roll);                     //accessing member with period operator

    return 0;
}

------------------------------------------------------------------------------------------
or
--------------------------------------------------------------------------------
using codeblocks
----------------------------------------------------------------------------------------------------------------------
// program to initialize data in struct            //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

};
struct data access={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki                                                                           //and 34 are    data.

int main()
{

   puts("name is\n");
   puts(access.name);                             //accessing member with period operator
   puts("address is\n");
   puts(access.address);                          //accessing member with period operator
   puts("roll number is\n");
   printf("%d",access.roll);                     //accessing member with period operator

    return 0;
}

------------------------------------------------------------------------------------------
using turbo c++
--------------------------------------------------------------------------------

// program to initialize data in struct            //comment abt. program
#include <stdio.h>                                 //header file
#include<conio.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={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are                                                              //data.

int main()
{

   puts("name is\n");
   puts(access.name);                             //accessing member with period operator
   puts("address is\n");
   puts(access.address);                          //accessing member with period operator
   puts("roll number is\n");
   printf("%d",access.roll);                     //accessing member with period operator
   getch();
    return 0;
}

program to reverse a a string using function.

using codeblocks
-------------------------------------------------------------------------------------------------

// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
void string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    string_reverse();                       // function calling
    return 0;                              // returning value 0
}
void string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string");                   // message declaration
  gets(string);                           // gets string from user
  strrev(string);                        // reverses the string and stores in memory
  puts(string);                      // displays  that reversed string
}
---------------------------------------------------------------------------------------------------

using Turbo c++
----------------------------------------------------------------------------------------------------
// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
#include<conio.h>
void string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    string_reverse();                       // function calling
   getch();                                   //holds the output
    return 0;                              // returning value 0

}
void string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string");                   // message declaration
  gets(string);                           // gets string from user
  strrev(string);                        // reverses the string and stores in memory
  puts(string);                      // displays  that reversed string
}

program to get length of string using function

using codeblocks

---------------------------------------------------------------------------------------------------------------

// program to get length of a string          // title of program

#include <stdio.h>                           // header file to control input and output

#include<string.h>                           //header file to handle string function

void string_length();                       // function prototype

int main()                                  // main function returning integer value

{

    string_length();                       // function calling

    return 0;                              // returning value 0

}

void string_length()                       // function body

{

  char string[100];                       // string declaration

  puts("enter string");                   // message declaration

  gets(string);                           // gets string from user

  printf("length=%d",strlen(string));     // displays length with the help of strlen() function

}

---------------------------------------------------------------------------------------------
using turbo c++
---------------------------------------------------------------------------------------------------------
// program to get length of a string          // title of program
#include <stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
#include<conio.h>                          // header file to control console input and output
void string_length();                       // function prototype
int main()                                  // main function returning integer value
{
    string_length();                       // function calling
    getch();                                 // holds input and output
    return 0;                              // returning value 0
}
void string_length()                       // function body
{
  char string[100];                       // string declaration
  puts("enter string");                   // message declaration
  gets(string);                           // gets string from user
  printf("length=%d",strlen(string));     // displays length with the help of strlen() function

}

programs for storage classes

programs for storage classes

click the link below.

----------------------------------------------------------------------------------------------

Storage class:- We understand here some programs which use different storage concept.


1) Automatic (also called local variables):

2) External storage (also called global storage or variables:

3)static storage:-

4)register storage:-