#include<iostream.h>
#include<conio.h>
void calavg( int [6][3]);
char calgrade(int);
double calgpa(int);
void calavg(int a[][3])
{
int avg,i,j;
for( i=0;i<=2;i++)
{
avg=0;
for( j=0;j<5;j++)
avg=avg+a[j][i];
avg=avg/j;
a[5][i]=avg;
}
}
char calgrade(int stdmarks)
{
char g;
if(stdmarks>0 && stdmarks<50)
g='F';
else if(stdmarks>=50 && stdmarks<60)
g='D';
else if(stdmarks>=60 && stdmarks<70)
g='C';
else if(stdmarks>=70 && stdmarks<80)
g='B';
else if(stdmarks>=80 && stdmarks<=100)
g='A';
return g;
}
double calgpa(int stdmarks)
{
double g;
if(stdmarks>0 && stdmarks<50)
g=0;
else if(stdmarks>=50 && stdmarks<60)
g=1;
else if(stdmarks>=60 && stdmarks<70)
g=2;
else if(stdmarks>=70 && stdmarks<80)
g=3;
else if(stdmarks>=80 && stdmarks<=100)
g=4;
return g;
}
int strcmp(char s1[],char s2[])
{
// int size=0;
// for(size=0;s1[size]!='\0';size++);
for(int i=0;s1[i]!='\0';i++)
{
if(s1[i]==s2[i])
{}
else
{
return s1[i]-s2[i];
}
}
return 0;
}
main()
{
clrscr();
int a[6][3],temp;
char name[5][20];
char grade[5][2];
int g[2];
char id[20];
int d;
//int id;
//this is for cgpa:array
double cgpa[5];
int opt,i,j,sum,avg,v=0,gpa;
//this is for float:
double sum1;
for(i=0;i<5;i++)
{
cout<<"Enter the name of std"<<i+1<<": ";
cin>>name[i];
}
v:
cout<<"press 1 to enter marks for pf and 2 for itc : ";
cin>>opt;
if(opt==1)
{
cout<<"pf\n";
for( i=0;i<5;i++)
{
for( j=0;j<=0;j++)
{
cout<<"enter marks "<<name[i]<<" : ";
cin>>a[i][j];
}
}
v++;
if(v<2)goto v;
}
if(opt==2)
{
cout<<"itc\n";
for( i=0;i<5;i++)
{
for(j=1;j<=1;j++)
{
cout<<"enter marks:";
cin>>a[i][j];
}
}
v++;
if(v<2)goto v;
}
for(i=0;i<5;i++)
{
sum=0;
for(j=0;j<2;j++)
{
sum=sum+a[i][j];
a[i][2]=sum;
}
}
//without fun cal avg method:
/*for(i=0;i<=2;i++)
{
avg=0;
for(j=0;j<5;j++)
avg=avg+a[j][i];
avg=avg/j;
a[5][i]=avg;
}*/
calavg(a);
cout<<"marks sheet:\n";
cout<<"name\tpf\titc\tsum\n";
for( i=0;i<=5;i++)
{
if(i<5)
cout<<name[i]<<"\t";
else
cout<<"----------------------------------------\navg:\t";
for( j=0;j<=2;j++)
cout<<a[i][j]<<"\t";
cout<<"\n";
}
cout<<"Grade Sheet:\n";
// this for cgpa cal chek kar:yahan say baqie thk hai:
for(i=0;i<5;i++)
{
sum1=0;
for(j=0;j<2;j++)
{
sum1=sum1+calgpa(a[i][j]);
}
sum1=sum1/j;
cgpa[i]=sum1;
}
cout<<"name\tpf\titc\tcgpa\n";
for(i=0;i<5;i++)
{
for(j=0;j<2;j++)
grade[i][j]=calgrade(a[i][j]);
}
for(i=0;i<5;i++)
{
if(i<5)
cout<<name[i]<<"\t";
for(j=0;j<2;j++)
{
cout<<grade[i][j]<<"\t";
}
cout<<cgpa[i];
cout<<"\n";
}
// this for course avg.gpa:
for(i=0;i<1;i++)
{
for(j=0;j<2;j++)
g[j]=calgpa(a[5][j]);
}
cout<<"............................\nc.gpa\t";
for(j=0;j<2;j++)
{
cout<<g[j]<<"\t";
}
// display course statistics:
cout<<"\n\ncourse statistics\n\n";
for(i=0;i<2;i++)
{
cout<<"\npress 1 for pf statistics and 2 for itc: ";
cin>>opt;
if(opt==1)
cout<<"\npf avgerege course marks:"<<a[5][0]<<"\n";
if(opt==2)
cout<<"\nitc avgerege course marks:"<<a[5][1]<<"\n";
}
/*
for(i=0;i<5;i++)
{
for(int j=0;j<=0;j++)
{
for(int k=0;k<3;k++)
{
if(a[i][j]<a[i+1][j])
temp=a[i][j];
a[i][j]=a[i+1][j];
a[i+1][j]=temp;
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<=0;j++)
cout<<a[i][j]<<"\n";
}
*/
// searching portion:
cout<<"\n search for student id for marks,grade and cgpa:\n";
cout<<"Enter the std id:";
cin>>id;
for(i=0;i<5;i++)
{
/*if(id==name[i])
{
break;
}
*/
if(strcmp(id,name[i])==0)
{
cout<<"mark sheet:\n";
cout<<"name\tpf\titc\n";
cout<<name[i]<<"\t";
for(j=0;j<2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<"\n";
cout<<"grade sheet:\n";
cout<<"pf\titc\tcgpa\n";
for(j=0;j<2;j++)
{
cout<<grade[i][j]<<"\t";
}
cout<<cgpa[i];
break;
}
}
getch();
}
#include<conio.h>
void calavg( int [6][3]);
char calgrade(int);
double calgpa(int);
void calavg(int a[][3])
{
int avg,i,j;
for( i=0;i<=2;i++)
{
avg=0;
for( j=0;j<5;j++)
avg=avg+a[j][i];
avg=avg/j;
a[5][i]=avg;
}
}
char calgrade(int stdmarks)
{
char g;
if(stdmarks>0 && stdmarks<50)
g='F';
else if(stdmarks>=50 && stdmarks<60)
g='D';
else if(stdmarks>=60 && stdmarks<70)
g='C';
else if(stdmarks>=70 && stdmarks<80)
g='B';
else if(stdmarks>=80 && stdmarks<=100)
g='A';
return g;
}
double calgpa(int stdmarks)
{
double g;
if(stdmarks>0 && stdmarks<50)
g=0;
else if(stdmarks>=50 && stdmarks<60)
g=1;
else if(stdmarks>=60 && stdmarks<70)
g=2;
else if(stdmarks>=70 && stdmarks<80)
g=3;
else if(stdmarks>=80 && stdmarks<=100)
g=4;
return g;
}
int strcmp(char s1[],char s2[])
{
// int size=0;
// for(size=0;s1[size]!='\0';size++);
for(int i=0;s1[i]!='\0';i++)
{
if(s1[i]==s2[i])
{}
else
{
return s1[i]-s2[i];
}
}
return 0;
}
main()
{
clrscr();
int a[6][3],temp;
char name[5][20];
char grade[5][2];
int g[2];
char id[20];
int d;
//int id;
//this is for cgpa:array
double cgpa[5];
int opt,i,j,sum,avg,v=0,gpa;
//this is for float:
double sum1;
for(i=0;i<5;i++)
{
cout<<"Enter the name of std"<<i+1<<": ";
cin>>name[i];
}
v:
cout<<"press 1 to enter marks for pf and 2 for itc : ";
cin>>opt;
if(opt==1)
{
cout<<"pf\n";
for( i=0;i<5;i++)
{
for( j=0;j<=0;j++)
{
cout<<"enter marks "<<name[i]<<" : ";
cin>>a[i][j];
}
}
v++;
if(v<2)goto v;
}
if(opt==2)
{
cout<<"itc\n";
for( i=0;i<5;i++)
{
for(j=1;j<=1;j++)
{
cout<<"enter marks:";
cin>>a[i][j];
}
}
v++;
if(v<2)goto v;
}
for(i=0;i<5;i++)
{
sum=0;
for(j=0;j<2;j++)
{
sum=sum+a[i][j];
a[i][2]=sum;
}
}
//without fun cal avg method:
/*for(i=0;i<=2;i++)
{
avg=0;
for(j=0;j<5;j++)
avg=avg+a[j][i];
avg=avg/j;
a[5][i]=avg;
}*/
calavg(a);
cout<<"marks sheet:\n";
cout<<"name\tpf\titc\tsum\n";
for( i=0;i<=5;i++)
{
if(i<5)
cout<<name[i]<<"\t";
else
cout<<"----------------------------------------\navg:\t";
for( j=0;j<=2;j++)
cout<<a[i][j]<<"\t";
cout<<"\n";
}
cout<<"Grade Sheet:\n";
// this for cgpa cal chek kar:yahan say baqie thk hai:
for(i=0;i<5;i++)
{
sum1=0;
for(j=0;j<2;j++)
{
sum1=sum1+calgpa(a[i][j]);
}
sum1=sum1/j;
cgpa[i]=sum1;
}
cout<<"name\tpf\titc\tcgpa\n";
for(i=0;i<5;i++)
{
for(j=0;j<2;j++)
grade[i][j]=calgrade(a[i][j]);
}
for(i=0;i<5;i++)
{
if(i<5)
cout<<name[i]<<"\t";
for(j=0;j<2;j++)
{
cout<<grade[i][j]<<"\t";
}
cout<<cgpa[i];
cout<<"\n";
}
// this for course avg.gpa:
for(i=0;i<1;i++)
{
for(j=0;j<2;j++)
g[j]=calgpa(a[5][j]);
}
cout<<"............................\nc.gpa\t";
for(j=0;j<2;j++)
{
cout<<g[j]<<"\t";
}
// display course statistics:
cout<<"\n\ncourse statistics\n\n";
for(i=0;i<2;i++)
{
cout<<"\npress 1 for pf statistics and 2 for itc: ";
cin>>opt;
if(opt==1)
cout<<"\npf avgerege course marks:"<<a[5][0]<<"\n";
if(opt==2)
cout<<"\nitc avgerege course marks:"<<a[5][1]<<"\n";
}
/*
for(i=0;i<5;i++)
{
for(int j=0;j<=0;j++)
{
for(int k=0;k<3;k++)
{
if(a[i][j]<a[i+1][j])
temp=a[i][j];
a[i][j]=a[i+1][j];
a[i+1][j]=temp;
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<=0;j++)
cout<<a[i][j]<<"\n";
}
*/
// searching portion:
cout<<"\n search for student id for marks,grade and cgpa:\n";
cout<<"Enter the std id:";
cin>>id;
for(i=0;i<5;i++)
{
/*if(id==name[i])
{
break;
}
*/
if(strcmp(id,name[i])==0)
{
cout<<"mark sheet:\n";
cout<<"name\tpf\titc\n";
cout<<name[i]<<"\t";
for(j=0;j<2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<"\n";
cout<<"grade sheet:\n";
cout<<"pf\titc\tcgpa\n";
for(j=0;j<2;j++)
{
cout<<grade[i][j]<<"\t";
}
cout<<cgpa[i];
break;
}
}
getch();
}
its not compiling in dev c++
ReplyDeletea lot of errors
A lot of errors in Dec c+++
ReplyDelete