Define a function with the prototype
void ocpl(char str[]);
that prints each character in the string str on a line by itself.
c++
Program Code Screenshot:
Sample Output:
The screenshots are attached below for reference.
Please follow them for proper output.
Program code to copy:
#include <iostream>
using namespace std;
void ocpl(char str[]);
void ocpl(char str[]){//function definition
int i=0;
while(str[i]!='\0'){//for each character of string
cout<<str[i]<<endl;//print in a newline
i++;
}
}
int main() {
char s[]="string";
ocpl(s);//call function
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.