Question

Define a function with the prototype void ocpl(char str[]); that prints each character in the string...

Define a function with the prototype

void ocpl(char str[]);

that prints each character in the string str on a line by itself.

c++

Homework Answers

Answer #1

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;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a function to find the last occurrence of a string within another string. The function...
Write a function to find the last occurrence of a string within another string. The function should use the prototype below. Use pointer arithmetic when traversing the strings. (C Language) char * search_string(const char * str, const char * substr);
use c language only to solve this porblem -------------------------- Have the function StringChallenge(str) take the str...
use c language only to solve this porblem -------------------------- Have the function StringChallenge(str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces. Examples Input: "Hello World" Output: 2 Input: "one 22 three" Output: 3 you have the following code what edits can you do #include <stdio.h> #include <string.h> void StringChallenge(char str[]) {      // code goes...
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 extern char **environ;    5 void output(char *a[], char...
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 extern char **environ;    5 void output(char *a[], char *b[]) { 6 int c = atoi(a[0]); 7 for (int i = 0; i < c && b[i]; ++i) { 8 printf("%s", b[i]+2); 9 } 10 } 11 12 void main(int argc, char *argv[]) { 13      14 switch (argc) { 15 case 1: 16 for (int i = 0; environ[i]; ++i) {    17 printf("%s\n", environ[i]); 18 } 19 break; 20 default: 21 output(argv +...
#include <stdio.h> #define K   1024 /** (2pts) * Copy the string in src to dst. Only...
#include <stdio.h> #define K   1024 /** (2pts) * Copy the string in src to dst. Only copy as many characters (including the * null character) that are in src to dst. Points will be deducted for copying * too many or too few characters. */ void my_strcpy(char dst[], char src[]) { } int main(void) { char input[K+1], copy[K+1]; // Get a line of input (up to K number of bytes) into the 'input' string: // Do not modify any of...
Write a function int count_consonants(char str[]) that determines and returns the number of consonants in a...
Write a function int count_consonants(char str[]) that determines and returns the number of consonants in a given string. Then write a simple main() function where you can repeatedly enter a string and then the num- ber of consonants is determined and printed on the screen (from the main() function). If the entered string is empty (it will contain only a ’\n’ then) the program should stop its execution. You can safely assume that the entered string will be not longer...
C++ only: Please implement a function that accepts a string parameter as well as two character...
C++ only: Please implement a function that accepts a string parameter as well as two character arguments and a boolean parameter. Your function should return the number of times it finds the character arguments inside the string parameter. When both of the passed character arguments are found in the string parameter, set the boolean argument to true. Otherwise, set that boolean argument to false. Return -1 if the string argument is the empty string. The declaration for this function will...
write a function call character_thing (string, character) that takes in a string and a character. The...
write a function call character_thing (string, character) that takes in a string and a character. The function will return the number of times the character appears in the string. please be in python
write a program (in Java/Eclipse to loop through a string character by character. If the character...
write a program (in Java/Eclipse to loop through a string character by character. If the character is a letter, print a question mark, otherwise print the character. Use the code below for the message string. This will be the first string that you will decode. Use the String class method .charAt(index) and the Character class method .isLetter(char). (You can cut and paste this line into your program.) String msg = "FIG PKWC OIE GJJCDVKLC MCVDFJEHIY BIDRHYO.\n";
Experience with Functions Are the following statements a function header, a prototype or a function call?...
Experience with Functions Are the following statements a function header, a prototype or a function call? double calcMonthlyPmt(double amt); void displayResults() void showMenu(); showNum(45.67); area = CalArea(5,10); Write the function calls for the following headers and prototypes: void showValue(int quantity) void display(int arg1, double arg2, char arg3); pass the following to the call: int age; double income; char initial double calPay(int hours, double rate); What is the output of the following program? #include <iostream> using namespace std; void showDouble(int); //Function...
The function martian() has a prototype of: void martian(int ch); and an implementation of: void (int...
The function martian() has a prototype of: void martian(int ch); and an implementation of: void (int ch) { printf("%c" ,ch); return; } it is called from main as int md= 0x45; martian(md); What is printed on the screen?