Lab 10 (Recursion).docx - CSL-113 Computer Programming Lab Semester BS CS \u2013 01-C Lab#10 CSL 113 Computer Programming Lab Fall 2018 Name Sana Minhaj

Lab 10 (Recursion).docx - CSL-113 Computer Programming Lab...

This preview shows page 1 - 5 out of 17 pages.

CSL-113: Computer Programming Lab Semester BS CS – 01-C Lab #10 CSL 113 - Computer Programming Lab Fall 2018 Name: Sana Minhaj Class: BS (CS) 1-C Enrollment Number: 02-134172-081 Submitted to: Sir Tarwan Kumar Department of Computer Sciences 1/17 Semester BSCS 01 CSL-113: Computer Programming Lab Lab 10: Function Overloading and Recursion
Image of page 1
CSL-113: Computer Programming Lab Semester BS CS – 01-C CP Lab #10 Task 1: Write a C++ program for calculating grades of students. int main(): prompt user for the number of subjects for which he/she wants to calcuclate the grade 2 or 3. prompt for marks with respect to their early selection call calgrades() according to their selection. o For example calgrades(s1,s2) // for two subjects. o calgrades(s1,s2,s3) // for three subjects. Calgrades(): Function(s) must be overloaded accordingly. These functions determine the grade of student on following criteria: A grade : 87 - 100 B grade : 75 – 86 C grade : 65 – 74 D grade : 50 – 64 F grade : < 50 Code: #include<iostream> using namespace std; int grades (int s1, int s2); int grades (int s1,int s2,int s3); int main() { int a,b,c; int ch; cout<<"Please enter the number of subjects for your grade: "; cin>>ch; switch (ch) case 1: { { cout<<"Sorry Invalid Input"; return 0; break; } Department of Computer Sciences 2/17 Semester BSCS 01 CSL-113: Computer Programming Lab Lab 10: Function Overloading and Recursion
Image of page 2
CSL-113: Computer Programming Lab Semester BS CS – 01-C case 2: { { cout<<"please enter marks for first subject: "; cin>>a; cout<<endl; cout<<"please enter marks for second subject: "; cin>>b; grades (a,b); break; } case 3: { cout<<"Please enter marks for first subject: "; cin>>a; cout<<endl; cout<<"Please enter marks for second subject: "; cin>>b; cout<<endl; cout<<"Please enter marks for third subject: "; cin>>c; grades (a,b,c); break; } } } Department of Computer Sciences 3/17 Semester BSCS 01 CSL-113: Computer Programming Lab Lab 10: Function Overloading and Recursion
Image of page 3
CSL-113: Computer Programming Lab Semester BS CS – 01-C return 0; } int grades (int s1,int s2) { int sum; float div;
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 17 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture