Home Basic Loop Array string Function Pointer Contact STUDY

# AHF    C    PROGRAM    SOLVING

### Calculate result CGPA in one subject

```
// AHF C PROGRAM SOLVING

//solving here basic type of programming problem

#include<stdio.h>
#include<math.h>
#define pf printf
int main()
{
float sum,AT,CT1,CT2,QT1,QT2,QT3,ASN,MID,FINAL,best_CT,best_QT;

pf("\nEnter the attendence number( AT ): ");
scanf("%f",&AT);

if(AT>=0 && AT<=5)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 5 marks.");

pf("\n\nEnter the first class test number ( CT1): ");
scanf("%f",&CT1);

if(CT1>=0 && CT1<=10)
pf("\v\tVailed input.");
else
pf("\n\tPlease enter 0 to 10 marks.");

pf("\n\nEnter the second class test number: ");
scanf("%f",&CT2);

if(CT2>=0 && CT2<=10)
pf("\n\tVailed input.");
else
pf("\n\tPlease Enter 0 to 10 marks.");

pf("\n\nEnter the first quize test number( QT1 ): ");
scanf("%f",&QT1);

if(QT1>=0 && QT1<=5)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 5 marks.");

pf("\n\nEnetr the second quize test number( QT2 ): ");
scanf("%f",&QT2);

if(QT2>=0 && QT2<=5)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 5 marks.");

pf("\n\nEnter third quiz test number( QT3 ): ");
scanf("%f",&QT3);

if(QT3>=0 && QT3<=5)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 5 marks.");

pf("\n\nEnetr assignment number( ASN ): ");
scanf("%f",&ASN);

if(ASN>=0 && ASN<=10)
pf("\n\tVailed input.");
else
pf("\n\tPease enter 0 to 10 marks");

pf("\n\nEnter MID - term examination number( MID ): ");
scanf("%f",&MID);

if(MID>=0 && MID<=30)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 30 marks.");

pf("\n\nEnter final examination number( FINAL ): ");
scanf("%f",&FINAL);

if(FINAL>=0 && FINAL<=40)
pf("\n\tVailed input.");
else
pf("\n\tPlease enter 0 to 40 marks.");

best_CT=CT1>CT2?CT1:CT2;

best_QT=QT1>QT2?(QT1>QT3?QT1:QT3):(QT2>QT3?QT2:QT3);

pf("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");

pf("\nAttandance number: %.2f",AT);

pf("\nBest count of class test= %.2f",best_CT);

pf("\nBest count of quize test= %.2f",best_QT);

pf("\nAssignment number= %.2f",ASN);

pf("\nMID - term examination number= %.2f",MID);

pf("\nFinal examination number= %.2f",FINAL);

pf("\n\n|||||||||||||||||||||||||||||||||||||||||||||||||||||");

sum=AT+best_CT+best_QT+ASN+MID+FINAL;

pf("\n\nTHE TOTAL NUMBER, GAINED BY THE STUDENT, OF A STUDENT= %.2f",sum);

return 0;
}

```
OUTPUT: