Showing posts with label Student. Show all posts
Showing posts with label Student. Show all posts

C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division

Write a C or C++ program to read marks of 4 subjects and find how many students are pass and fail with division.

This program to read marks of 4 subjects and find how many students are pass and fail with division.

To read marks of 4 subjects and find out how many students fall under the following categories:

a) avg<45 - Fail
b) 45 <= avg <55- Third Division
c) 55<= avg <60 - Second Division
d) 60<= avg <75 - First Division
e) avg >=75 - Distinction

Solution For C Program:

C Program To Store Students Record In A Text File

How to write a C Program To Store Students Record In A Text File in C Programming Language ?


Solution For C Program :

/*C Program To Store Students Record In A Text File.*/


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
    FILE *fp;
    char another='y';
    int marks1,marks2,marks3,marks4,marks5,role;
    char name[20];
    clrscr();

    fp=fopen("Students.txt","w");
    if(fp==NULL)
    {
        puts("Cannot open file");
        exit(1);
    }
       fprintf(fp,"Role No.\tNAME\t  PHYSICS  CHEMISTRY  MATHS  S.S.T  ENGLISH\n");
    while(another=='y')
    {
        printf("\nEnter name :");
        scanf("%s",&name);
        printf("Enter your Role No.:");
        scanf("%d",&role);
        printf("Enter marks in Physics:");
        scanf("%d",&marks1);
        printf("Enter marks in Chemistry:");
        scanf("%d",&marks2);
        printf("Enter marks in Mathematics:");
        scanf("%d",&marks3);
        printf("Enter marks in Social Science:");
        scanf("%d",&marks4);
        printf("Enter marks in English:");
        scanf("%d",&marks5);
        fprintf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%d\n",role, name, marks1,marks2,marks3,marks4,marks5);
        printf("Add another record (y/n): ");
        fflush(stdin);
        another=getche();
    }
    fclose(fp);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program - Hash Table to store information about a student

How to write a C Program to create a Hash table taking in student name, class and total marks; display students' details based on class; search based on student's name and Display highest marks in the class in C Programming Language ?

Hash tables are commonly used because of their speed searching takes on average constant time, whereas trees take logarithmic time, and linked lists searching takes linear time.

https://en.wikipedia.org/wiki/Hash_table

Solution:
/* Hash table taking in student name, class and total marks; display students' details based on class; search based on student's name and Display highest marks in the class */
//Implementation of a Hash Table to store information about a student.