Hello There, Guest! Login Register
Advertise Here | Remove Ads

C Program to Store Information(name, roll and marks) of a Student Using Structure

  • 0 Vote(s) - 0 Average


07-08-2016, 05:47 PM #1
Mitu Offline FFU SENIOR FFU SENIOR
VIP MEMBER
Posts:2,183 Threads:175 Joined:Sep 2014 Reputation: 2 Sex Female
Country: Bangladesh
Code:
#include <stdio.h>
struct student{
    char name[50];
    int roll;
    float marks;
};
int main(){
    struct student s;
    printf("Enter information of students:\n\n");
    printf("Enter name: ");
    scanf("%s",s.name);
    printf("Enter roll number: ");
    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;
}

In this program, a structure(student) is created which contains name, roll and marks as its data member. Then, a structure variable(s) is created. Then, data (name, roll and marks) is taken from user and stored in data members of structure variable s. Finally, the data entered by user is displayed.

[Image: 468x60_2.gif]






Forum Jump:


Users browsing this thread:1 Guest(s)

Advertise Here | Remove Ads