Home Education CS201 Assignment Fall 2021 Complete Solution

CS201 Assignment Fall 2021 Complete Solution

by Koustubh Verma
CS201 Assignment Fall 2021

Are you looking for CS201 assignment File 2021 Solution? If yes, then you landed at the exact page. Because today, I am going to offer you best and accurate solution of CS201 assignment fall 2021 to attain good and full marks.

Remember that you just needed to Change the following in this solution file. Else all will remain same, to get full marks in CS201 assignment.

  • Change Your Name
  • Change Your VULMS ID
  • Change Last Three Digit

Cs201 Assignment Fall 2021 File Complete Solution

#include <iostream>

#include <string>

using namespace std;

void printnameid(string studentid, string studentname);

int calculatelastthreedigits(string studentid);

int main()

{

    string studentid=”BC200201353″; // Student id

    string studentname=”Usman”; // Student name

    printnameid(studentid,studentname);

    int TotalLastThreeDigits=calculatelastthreedigits(studentid);

    int counter=1;

    int a,b,c;

    // Students id last 3 digits

    a=3;

    b=5;

    c=3;

    cout<<“”<<endl;

    cout<<“Sum of Last 3 digits is=”<<a+b+c<<endl;

    cout<<“”<<endl;

    if ( TotalLastThreeDigits % 2 == 0)   // Divide by 2 and see if the reminder is zero? then it is even otherwise it is odd number

    {

       cout<< ”   Sum is an even value “<<endl;

   cout<<“”<<endl;

   cout<<“++++++++++++++++++++++++++++++++++++++++++++”<<endl;

   cout<<“”<<endl;

       while(counter <= TotalLastThreeDigits)

       {

           cout << ” Iteration: ” <<counter <<endl;

           cout << “My student id is:” <<studentid<<endl;

           counter++;

       }

    }    

    else

    {

       cout << ”   Sum is an odd value:”<<endl;      

       while(counter <= TotalLastThreeDigits)

       {

           cout<< ” Iteration: “<<counter<<endl;

           cout<< “My name is “<<studentname<<endl;

           counter++;

       }

    }

    return 0;

}

void printnameid(string studentid, string studentname){

    cout<<” My name “<<studentname <<endl;

    cout<<” My student id is “<<studentid<<endl;

}

int calculatelastthreedigits(string studentid) {

    int end=studentid.length(); // Ending point that is total length of string

    int start=end-3;  // Starting point

    string lastthreedigits=studentid.substr(start,end);  // Trim the last three digits;

    int total=0;

    //Calculate the sum of last three digits

    for ( int index=0; index < lastthreedigits.length(); index++) {

   total += lastthreedigits[index] – ‘0’;

}

    return total;

}

Make a Perfect Assignment to get good Marks:

Requirement One:

c 1 1

Requirement Two:

c2

Requirement Three:

c3

ConceptsBuilder

By Usman ALi

Related Posts

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.