Write a C program to store information of a student using structure?

#include<stdio.h>
#include<conio.h>
struct student
{
  char name[20];
  char branch[20];
  int roll;
  float grade;
}info;
int main()
{
  printf("***********************************************\n\n");
  printf("\tEnter information of the student");
  printf("\n\n***********************************************\n\n");

  printf("Enter name: ");
  gets(info.name);
  printf("Enter branch: ");
  gets(info.branch);
  printf("Enter roll no: ");
  scanf("%d",&info.roll);
  printf("Enter grade: ");
  scanf("%f",&info.grade);

  printf("\n*********************************************\n\n");
  printf("\tDisplaying Student Information");
  printf("\n\n*********************************************\n\n");

  printf("Name: ");
  puts(info.name);
  printf("Branch: ");
  puts(info.branch);
  printf("Roll No: ");
  printf("%d",info.roll);
  printf("\nGrade: ");
  printf("%0.3f",info.grade);

  getch();
}

Output:


  Note:-

  1. '\n' is used for new line.
  2. '\t' is used for tab( meams 4 times space ).






Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider