VU Answer Provide CS201 Assignment 1 Solution Fall 2021. Easy to See Correct CS201 Assignment 1 Solution 2021 for Fall and Download CPP, word, and pdf Solution File.
Please Check Below for the Latest CS201 Assignment
CS201 Assignment 1 Solution for Fall 2022 Current Semester - DOWNLOAD
CS201 ASSIGNMENT 1 SOLUTION FALL 2021
Provide by VU Answer
Due Date: 9 Dec 2021
Total Marks: 20
Provide .cpp and pdf solution files given below.
Assignment Format for Submission:
Submit your assignment only in .cpp format
Special Instruction Follows:
Use your own VU Id and Name only.
CODE Solution:
// WELCOME the program is written by Sarim Freely Provide ON VUAnswer.com
// Don’t worry if you need New changed CS201 Assignment free my WhatsApp +923162965677
#include <iostream>
#include <string>
using namespace std;
void printnameid(string studentid, string studentname);
int calculatelastthreedigits(string studentid);
int main()
{
string studentid="BC18020431"; // Student id
string studentname="Muhammad Sarim"; // Student name
printnameid(studentid,studentname);
int TotalLastThreeDigits=calculatelastthreedigits(studentid);
int counter=1;
int a,b,c;
// Students id last 3 digits
a=4;
b=3;
c=1;
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;
}
DOWNLOAD CS201 ASSIGNMENT SOLUTION CPP FILE
DOWNLOAD CS201 ASSIGNMENT SOLUTION PDF FILE
DOWNLOAD CS201 ASSIGNMENT SOLUTION WORD FILE
CODE RESULT
PLEASE NOTE:
Don't copy-paste the same.
Make sure you can make some changes and use your student’s id and name.
Before submitting an assignment check your assignment requirement file.
If you need some help and question about files and solutions.
Check Also:
0 Comments