The source code to perform the POP operation is given below. The given program is compiled and executed successfully.
// Rust program to perform POP operation
fn main() {
let mut countries = vec!["INDIA","USA"];
countries.push("UK");
countries.push("CANADA");
countries.push("ENGLAND");
println!("Countries are:\n{:?}", countries);
countries.pop();
countries.pop();
println!("\nCountries after POP operation:\n{:?}", countries);
}
Output:
Countries are:
["INDIA", "USA", "UK", "CANADA", "ENGLAND"]
Countries after POP operation:
["INDIA", "USA", "UK"]
Explanation:
Here, we created a vector to store the name of countries, and then we performed a PUSH operation to add the item into the vector and performed the POP operation to remove the item from the vector.
Program/Source Code:
The source code to perform the POP operation is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a vector to store the name of countries, and then we performed a PUSH operation to add the item into the vector and performed the POP operation to remove the item from the vector.
need an explanation for this answer? contact us directly to get an explanation for this answer