Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

C Program: Calculate Percentage & Check Pass/Fail Status of Student by Marks, Exercises of Digital & Analog Electronics

A c program that takes the name, id number, and marks of a student in five subjects as input and calculates their percentage. The program then checks whether the student has passed or failed based on the passing criteria of having marks above 35 in all subjects. The program also determines and displays the student's highest mark. This document could be useful for computer science students learning c programming and data structures.

What you will learn

  • What is the purpose of the provided C programming exercise?
  • How is the student's average calculated in the exercise?
  • What is the function of the 'pf' and 'large' functions in the exercise?

Typology: Exercises

2015/2016

Uploaded on 10/06/2016

aditya2395
aditya2395 🇮🇳

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exercise 1
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct result
{
char name[10];
int id;
int marks[5];
float p;
};
main()
{
struct result s1,*p1;
int i,total=0,max,n;
p1=&s1;
int pf(struct result*);
int large(struct result*);
printf("Enter the name:");
scanf("%s",p1->name);
printf("\nEnter the Id_no:");
scanf("%d",&p1->id);
printf("\nEnter marks of 5 subjects:");
pf3

Partial preview of the text

Download C Program: Calculate Percentage & Check Pass/Fail Status of Student by Marks and more Exercises Digital & Analog Electronics in PDF only on Docsity!

Exercise 1

#include<stdio.h> #include<stdlib.h> #include<conio.h> struct result { char name[10]; int id; int marks[5]; float p; }; main() { struct result s1,p1; int i,total=0,max,n; p1=&s1; int pf(struct result); int large(struct result*); printf("Enter the name:"); scanf("%s",p1->name); printf("\nEnter the Id_no:"); scanf("%d",&p1->id); printf("\nEnter marks of 5 subjects:");

for(i=0;i<5;i++) { printf("\nMarks of sub %d:",i+1); scanf("%d",&p1->marks[i]); total=total+p1->marks[i]; } p1->p=(total)/5; printf("\nPercantage=%f",p1->p); n=pf(p1); if(n==1) { printf("\nStudent is pass."); } else { printf("\nStudent is fail."); } max=large(p1); printf("\nHighest marks is=%d",max); }

int pf(struct result *p1) { if((p1->marks[0]>35) && (p1->marks[1]>35) && (p1->marks[2]>35) && (p1>marks[3]>35) && (p1->marks[4]>35)) { return 1; }