# Thread: Function, but mine is if else...

1. ## Function, but mine is if else...

So, there is my coding, but i use, loop, and if else, BUT the one suppose is Function...

Code:
```#include<iostream.h>
#include<string.h>
int main()
{
char lect_name[30],subject[30];
int mark;
int numbof_student;
float sum=0;
float average;

cout<<"Enter Your Lecturer name : ";
cin>>lect_name;

cout<<"Enter Your Subject code : ";
cin>>subject;

cout<<"Enter Number Of Student : ";
cin>>numbof_student;

for(int s=0; s<numbof_student; s++)
{

{
mark=4;
}

{
mark=3;
}

{
mark=2;
}

{
mark=1;
}

else
{
cout<<"Wrong Input"<<endl;
}
sum=sum+mark;

average=sum/numbof_student;

if ((average>=3.5) &&(average<=4.0))
{
cout<<"Excellence";
}

else if ((average<=3.0) &&(average<=3.5))
{
cout<<"Good";
}

else if ((average<=2.0) &&(average<=3.0))
{
cout<<"Average";
}

else if (average<=2.0)
{
cout<<"Poor";
}
}

cout<<"\n\n\t\tUniversiti Pendidikan Sultan Idris";
cout<<"\n\n\t\tTeaching & Learning Evaluation Report";
cout<<"\n\nName : "<<lect_name<<endl;
cout<<"Subject Code : "<<subject<<endl;
cout<<"Average :"<<average<<endl;
cout<<"Status : "<<status<<endl;
}```
i did coding for function, but blablabla... still error and error and then hard i try the simplest coding...

can sumone?

currently im still working to covert it to function...

2. Have you thought about using the switch case function? That would probably be alot more effecient, and use up alot less space =)

3. Currently im working to convert it to function coding...

and yes, i try to use, switch, but the typical problem is FUNCTION...

working...

4. This will probably help: C Function tutorial

yes, not above there, i did my function coding...

i had done my assignment with non-stop working...

without any help!

6. i had done my assignment with non-stop working...
welcome to the world of programming.....

well done...! :->

7. tq for ur help even not much.. TQ~

8. Recommend switch char to std::string.