Docsity

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

Toggle sidebar
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; }