Answer:
for ( initialization; condition;increment)
{
code goes here;
}
in python:
for i in list/range:
code with proper indentation
By initialization above we mean, like int i=0; etc.
By condition like i<10;
and by increment it means like i++, ++i or i+=1; etc
And in python, i can be an integer value if the range is mentioned, and it can be an item of a list if the list is used. We can also use an array, string and various other data structures in python. like we can have characters in a string and so on.
Explanation:
Please check the answer section.
Answer:
See Explaination
Explanation:
#include <iostream>
#include <string.h>
using namespace std;
char *mixem(char *s1, char *s2);
int main() {
cout << mixem("abc", "123") << endl;
cout << mixem("def", "456") << endl;
return 0;
}
char *mixem(char *s1, char *s2) {
char *result = new char[1 + strlen(s1) + strlen(s2)];
char *p1 = s1;
char *p2 = s2;
char *p = result;
while (*p1 || *p2) {
if (*p1) {
*p = *p1;
p1++;
p++;
}
if (*p2) {
*p = *p2;
p2++;
p++;
}
}
*p = '\0';
return result;
}
This is for Python
name = 'Joe'
print(f'My name is {name}')
This is called string formatting. Using f before the text. This is another way
name = 'Joe'
print('My name is', Joe)
But I found that string formatting is cleaner and much more useful