Answer:
// CPP program to Convert characters
// of a string to opposite case
#include<iostream>
using namespace std;
// Function to convert characters
// of a string to opposite case
void convertOpposite(string &str)
{
int ln = str.length();
// Conversion according to ASCII values
for (int i=0; i<ln; i++)
{
if (str[i]>='a' && str[i]<='z')
//Convert lowercase to uppercase
str[i] = str[i] - 32;
else if(str[i]>='A' && str[i]<='Z')
//Convert uppercase to lowercase
str[i] = str[i] + 32;
}
}
// Driver function
int main()
{
string str = "GeEkSfOrGeEkS";
// Calling the Function
convertOpposite(str);
cout << str;
return 0;
}
Explanation:
Answer:
Following are the correct code to this question:
short_names=['Gus','Bob','Zoe']#defining a list short_names that holds string value
print (short_names[0])#print list first element value
print (short_names[1])#print list second element value
print (short_names[2])#print list third element value
Output:
Gus
Bob
Zoe
Explanation:
- In the above python program code, a list "short_names" list is declared, that holds three variable that is "Gus, Bob, and Zoe".
- In the next step, the print method is used that prints list element value.
- In this program, we use the list, which is similar to an array, and both elements index value starting from the 0, that's why in this code we print "0,1, and 2" element value.
He should pick the most reliable one.
Hope this helps.
Answer:
a. You are eligible to vote.
Explanation:
If Age >= 18 Then
Write "You are eligible to vote."
Else
Set - Age
Write "You can vote in " + Years + " years."
End If
The above code block is an example of if-else code block. The if-else code block follow a pattern of:
If (expression) then
else
(expression)
end if
Based on the if Age>= 18 condition, the output will be "You are eligible to vote."