#include <iostream>
using namespace std;
class CarCounter {
public:
CarCounter();
CarCounter(const CarCounter& origCarCounter);
void SetCarCount(const int count) {
carCount = count;
}
int GetCarCount() const {
return carCount;
}
private:
int carCount;
};
CarCounter::CarCounter() {
carCount = 0;
return;
}
CarCounter::CarCounter(const CarCounter &p){
carCount = p.carCount;
}
void CountPrinter(CarCounter carCntr) {
cout << "Cars counted: " << carCntr.GetCarCount();
return;
}
int main() {
CarCounter parkingLot;
parkingLot.SetCarCount(5);
CountPrinter(parkingLot);
return 0;
}
Sample output:
Cars Counted: 5
Answer:
Following are the program in python language:
def list_concat(ls): #define function
if(len(ls) == 0): #set if condition
return ""
res = ""
for x in ls: #set for loop
res += x + " "
return res[:len(res)-1] #removing the extra spaces from list
ls = ['limit','break','ready'] #initialize the value in list
print(list_concat(ls)) #call the function
Output:
limit break ready
Explanation:
Here we declared a function "list_concat()" in which we pass an argument "ls" then check if condition that check the length of list .We also Iterating the loop in that function res[:len(res)-1] statement removes the extra space from the list and finally print the list
Explanation: The CPU is the main control chip which calculates what has to be done in order for your computer to function.
(Very interesting question you had. Hope this answer helps)
Answer:
painter = {'name' : "Vincent van Gogh", 'artworks': ["The Starry Night","Irises","The Potato Eaters"],'bornDate': "March 30, 1853", 'eyeColor': "July 29, 1890", 'diedDate': "July 29, 1890"} #this is a code which holds the questions defined value in a painter variable.
Explanation:
- The above question wants to declare a variable that is in the form of a key and value pair.
- The above question states to define name, artworks,eyeColor, and dieddate as a key and the other is defined as a value.
- when a user wants to access the whole dictionary then he can do with the help of the painter variable.
- But when he wants to access the value of any particular key, then he can do it with the help of the key name as "painter[keyname]".