www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS201 Introduction to Programming Assignment 01 Fall 2021 Solution / Discussion

CS201 Introduction to Programming Assignment 01 Fall 2021 Solution / Discussion

Views: 764

### Replies to This Discussion

Share the Assignment Questions & Discuss Here....

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

also waiting for this.

# CS201 Assignment 1 Solution Fall 2021 | CS201 Assignment Solution 2021

#cs201assignment1solutionfall2021 #cs201assignmentsolution2021
CS201 Assignment 1 Solution Fall 2021 | CS201 Assignment Solution 2021

cs 201 assignment 1 solution
#include <iostream>
using namespace std ;
int main ()
{
int Sum,a,b ;
Sum = 0 ;
a = 1 ;
b = 1 ;
cout" My Name is XYZ \n \n" endl;
cout " My Student Id is Bc190405158\n \n" endl;
cout"+++++++++++++++++++++ \n \n";
Sum = 1+5+8 ;
cout " Sum Of last three digits is = \n "Sumendl;
cout"++++++++++++++++++++ \n \n ";
if ( Sum % 2 == 0)
{
cout"Sum is Even \n \n"endl;
while (a<=Sum)
{
cout"iteration:" aendl;
cout "Bc190405158"endl;
a++ ;
}
}
else
{
cout"Sum is odd " bendl;
while(b<=Sum)
{
cout"iteration :" endl;
cout"My name is Aqib \n \n"endl;
b++ ;
return 0 ;
}

CS201 Assignment 1 Fall 2021 solution idea:

Code:

#include <iostream>
#include <string>

using namespace std;

void printnameid(string studentid, string studentname);
int calculatelastthreedigits(string studentid);

int main()
{
string studentid="MC12345678"; // Student id
string studentname="QueryVU"; // 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+cendl;
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:" studentidendl;
counter++;
}
}
else
{
cout " Sum is an odd value:"endl;
while(counter <= TotalLastThreeDigits)
{
cout " Iteration: "counterendl;
cout "My name is "studentnameendl;
counter++;
}
}
return 0;
}

void printnameid(string studentid, string studentname){
cout" My name "studentname endl;
cout" My student id is "studentidendl;
}

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';
}
}

********

correct code is here error free

#include <iostream>
#include <string>

using namespace std;

void printnameid(string studentid, string studentname);
int calculatelastthreedigits(string studentid);

int main()
{
string studentid="Bc210206508"; // Student id
string studentname="Zack Knight"; // Student name

printnameid(studentid,studentname);
int TotalLastThreeDigits=calculatelastthreedigits(studentid);
int counter=1;

cout""endl;
cout"Sum of Last 3 digits is="TotalLastThreeDigitsendl;
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:" studentidendl;
counter++;
}
}
else
{
cout " Sum is an odd value:"endl;
while(counter <= TotalLastThreeDigits)
{
cout " Iteration: "counterendl;
cout "My name is "studentnameendl;
counter++;
}
}
return 0;
}

void printnameid(string studentid, string studentname){
cout" My name "studentname endl;
cout" My student id is "studentidendl;
}

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';
}
}

# CS201 Assignment No 1 Solution Fall 2021

CS201 Assignment#01 Fall 2021 December 2021 Solution file

CS201-Assignment-01-Solution-Fall-2021_VU_Ning.pdf

CS201-Assignment-1-Solution-Fall-2021-Word-File

CS201-Assignment-1-Solution-Fall-2021-Word-File.docx

#cs201 #cs201assignment1correctsolution #CS201assignment1solution2021
CS201 Assignment 1 Fall 2021 100% Correct Complete Solution

1

2

3

4

## Latest Activity

### ENG 503 Midterm Fall 2022 5:30pm

23 minutes ago
2 hours ago
Aqib rehman liked Fahad Nabeel's discussion ISL201 1st Quiz
2 hours ago
Aqib rehman liked Fahad Nabeel's discussion ISL201 1st Quiz
2 hours ago
Aqib rehman and Masoom Shahzada joined Virtual University of Pakistan
2 hours ago

12 hours ago

12 hours ago

12 hours ago