-->
Showing posts with label Program read 10 students data (roll. Show all posts
Showing posts with label Program read 10 students data (roll. Show all posts

Program read 10 students data (roll, name,class and marks in 5 subjects) and display that using struct with percentage.

using codeblocks
--------------------------------------------------------------------------------------------------------------------------------
//Program read 10 students data (roll, name,class and marks in 5 subjects) and display that using //struct with percentage.                      //comment abt. program
#include <stdio.h>                                 //header file
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct
    int english,maths,physics,chemistry,nepali,total;   //marks member declaration
    float percentage;                       //member for total and percentage

}access[100];                 //'access' is a variable to access members. This can hold maximum 100 members.it is called array of struct.
int main()
{
   int n,i;                                         //variable declaration
   printf("enter total value of n\n");
   scanf("%d",&n);                                  //accepts total value
   for(i=0;i<n;i++)
   {                                                 //execution of loop with inputs
    puts("enter roll number \n");
   scanf("%d",&access[i].roll);                      //gets data in different member
   puts("enter name \n");
   scanf("%s",access[i].name);                       //gets name
   puts("enter address \n");
   scanf("%s",access[i].address);                    //gets address
   printf("enter english marks\n");
   scanf("%d",&access[i].english);                  //gets respective marks
   printf("enter maths marks\n");
   scanf("%d",&access[i].maths);
   printf("enter Physics marks\n");
   scanf("%d",&access[i].physics);
   printf("enter chemistry marks\n");
   scanf("%d",&access[i].chemistry);
   printf("enter nepali marks\n");
   scanf("%d",&access[i].nepali);
   access[i].total=access[i].english+access[i].maths+access[i].physics+access[i].chemistry+access[i].nepali;/finds total and stores
      access[i].percentage=(float)access[i].total/5;               //finds percentage and stores in respective member
   }
   printf("entered data are\n");                  //loop execution to display data
   for(i=0;i<n;i++)
   {
   printf("roll=%d,name=%s,address=%s, english=%d,maths=%d,physics=%d,chemistry=%d,nepali=%d\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali);
   }                                                //displays data

   printf(" data with total and percentage are\n");     // displays data with total and percentage
  for(i=0;i<n;i++)
   {
   printf("roll=%d,name=%s,address=%s, english=%d,maths=%d,physics=%d,chemistry=%d,nepali=%d, total=%d,percentage=%f\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali,access[i].total,access[i].percentage);
   }
    return 0;

}
-------------------------------------------------------------------------------------------------------------------------
using turbo c++
---------------------------------------------------------------------------------------
// program to enter detail of some  students       //comment abt. program
#include <stdio.h>                                 //header file
#include<conio.h>
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct
    int english,maths,physics,chemistry,nepali,total;   //marks member declaration
    float percentage;                       //member for total and percentage

}access[100];                 //'access' is a variable to access members. This can hold maximum 100 members.it is called array of struct.
int main()
{
   int n,i;                                         //variable declaration
   printf("enter total value of n\n");
   scanf("%d",&n);                                  //accepts total value
   for(i=0;i<n;i++)
   {                                                 //execution of loop with inputs
    puts("enter roll number \n");
   scanf("%d",&access[i].roll);                      //gets data in different member
   puts("enter name \n");
   scanf("%s",access[i].name);                       //gets name
   puts("enter address \n");
   scanf("%s",access[i].address);                    //gets address
   printf("enter english marks\n");
   scanf("%d",&access[i].english);                  //gets respective marks
   printf("enter maths marks\n");
   scanf("%d",&access[i].maths);
   printf("enter Physics marks\n");
   scanf("%d",&access[i].physics);
   printf("enter chemistry marks\n");
   scanf("%d",&access[i].chemistry);
   printf("enter nepali marks\n");
   scanf("%d",&access[i].nepali);
   access[i].total=access[i].english+access[i].maths+access[i].physics+access[i].chemistry+access[i].nepali;/finds total and stores
      access[i].percentage=(float)access[i].total/5;               //finds percentage and stores in respective member
   }
   printf("entered data are\n");                  //loop execution to display data
   for(i=0;i<n;i++)
   {
   printf("roll=%d,name=%s,address=%s, english=%d,maths=%d,physics=%d,chemistry=%d,nepali=%d\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali);
   }                                                //displays data

   printf(" data with total and percentage are\n");     // displays data with total and percentage
  for(i=0;i<n;i++)
   {
   printf("roll=%d,name=%s,address=%s, english=%d,maths=%d,physics=%d,chemistry=%d,nepali=%d, total=%d,percentage=%f\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali,access[i].total,access[i].percentage);
   }
   getch();                              //holds the output.
    return 0;
}