4/15/2016

C Program To Store Student Information Like (Name, Roll & Marks) Using Structure

Problem:- Write A C Program To Store Student Information Like (Name, Roll & Marks) Of Single Student Using Structure or C Program to Store Information of Students Using Structure or C Program to Store Information(name, roll, and marks) of a Student or Program to maintain student details using structures or C Program to read name and marks of students and store it in file or C Program to display student details using structure members or C Program to Read and Print details of 50 Students using Structure or C Program Using Structure to Calculate Marks of 10 Students or C Program to Store Records of Students in an Array or C Program to Sort Array of Structure using Bubble Sort or Program to Store Information of Students Using Structure in C or Structure Student (Name, Marks, Roll Number) Program in C or A program using structures in C to store student information.

What Is Structure

The structure is a user-defined data type in C. Structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age. You can define a structure to hold this information.

Defining a structure

struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.

Syntax :

struct structure_name
{
//Statements
};

Logic:- Here We Are storing a single student information like roll number, name and marks Not using for loop

So just define a structure like Below.


struct student
{
    char name[50];
    int roll;
    float marks;
};

Then Store the information in structure See the Example how Store the info in structure 

printf("Enter The Information of Students :\n\n");
    
printf("Enter Name : ");
scanf("%s",s.name);
    
printf("Enter Roll No. : ");
scanf("%d",&s.roll);
    
printf("Enter marks : ");
scanf("%f",&s.marks); 

And Then Displaying the Stored Information.

printf("Name: %s\n",s.name);
printf("Roll: %d\n",s.roll);
printf("Marks: %.2f\n",s.marks);

See The Below Problem For Handling a multiple Student Data Using Array, Like Name, Roll Number and Marks.

Try This C Program To Store Multiple Students Information of Using Structure

Solution:-

#include <stdio.h>
struct student
{
    char name[50];
    int roll;
    float marks;
};
int main()
{
  //Ghanendra Yadav
    struct student s;
    
printf("Enter The Information of Students :\n\n");
    
printf("Enter Name : ");
    scanf("%s",s.name);
    
printf("Enter Roll No. : ");
    scanf("%d",&s.roll);
    
    printf("Enter marks : ");
    scanf("%f",&s.marks);
    
    printf("\nDisplaying Information\n");
    
printf("Name: %s\n",s.name);
    printf("Roll: %d\n",s.roll);
    printf("Marks: %.2f\n",s.marks);
    return 0;
}

Output:-

C Program To Store Student Information Like (Name, Roll & Marks) Using Structure


You May Also See


1. C Program To Find Area And Circumference Of Circle

2. C Program To Print ASCII Value Of Character

3. C Program To Find Area Of Triangle

4. C Program to Convert a person's name in Abbreviated

5. C Program For Calculate A Simple Interest

6. C Program To Find Greater No. Among given Three Number

7. C Program For Find The Gross Salary Of An Employee

8. C Program For Calculate Percentage Of 5 Subjects

9. C Program For Converting Temperature Celsius Into Fahrenheit

10. C Program To Display Size Of Different Datatype


1 comment:

  1. Hey there, You have done a fantastic job. I will certainly digg it and personally suggest to my friends. I’m confident they’ll be benefited from this website.
    C Programming Courses in Chennai

    ReplyDelete