# Lab 1 exercise 1, Exercises for Digital & Analog Electronics. Dharamsinh Desai University

3 pages
116Number of visits
Description
Lab1
20 points
this document
Preview3 pages / 3

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;

}

else

{

return 0;

}

}

int large(struct result *p1)

{

int i,max=p1->marks[0];

for(i=0;i<5;i++)

{

if(p1->marks[i]>max)

{

max=p1->marks[i];

}

}

return(max);

}