Write a C program to accept and display details of one student (roll number, name, percentage) using structure.

C File =>


/* Write a program to create student structure having fields roll no,
name. Accept details of one student and write a function to
display the details. */


#include<stdio.h>
typedef struct Student
{
int rno;
char name[30];
float perc;
};


int main()
 {
  struct Student s;
  printf("\n Enter Roll Number : ");
  scanf("%d",&s.rno);
  printf("\n Enter Student name : ");
  scanf("%[^\n]s",s.name);
  printf("\nEnter Percentage : ");
  scanf("%f",&s.perc);
  printf("\n\n Details of Student are :\n");
  printf("\n Roll Number is : %d",s.rno);
  printf("\n Name is : %s",s.name);
  printf("\n Percentage : %f",s.perc);
  return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.