C program to print the student details(roll number, name ,branch and mark)-using structure.

C program
C PROGRAM 

 C program to print the student details using structure

#include<stdio.h>
#include<conio.h>
void main()
{
    struct structure1
    {
        int rollno;
        char name[30];
        char branch[10];
        int marks;
    }*stud,s;
    stud=&s;
    clrscr();
    printf("Enter roll no:\n");
    scanf("%d",&stud->rollno);
    printf("Enter a name:\n");
    scanf("%s",stud->name);
    printf("Enter branch:\n");
    scanf("%s",stud->branch);
    printf("Enter marks\n");
    scanf("%d",&stud->marks);
    printf("rollno:%d\n",stud->rollno);
    printf("Name:%s\n",stud->name);
    printf("branch:%s\n",stud->branch);
    printf("marks:%d\n",stud->marks);
    getch();
}

OUTPUT:

Enter roll no:
2
Enter a name:
Arun
Enter branch:
ECE
Enter marks
92
rollno:2
Name: Arun
branch: ECE
marks:92
[Process completed (code 10) - press Enter]

No comments:

Post a Comment




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.