1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anastasy [175]
4 years ago
6

Write a function strlen_recursive which accepts a pointer to a string and recursively counts the number of characters in the pro

vided string, excluding the null character. This function should return the number of characters in the string.
Computers and Technology
1 answer:
Over [174]4 years ago
7 0

Answer:

Following are the function

int strlen_recursive(char *str1)  // recursively counts

{

static int l=0; // static variable  

   if(*str1==NULL)  // string is equal to NULL

   {

     return(l);  // returning length

      }

   else

   {

       l++; // increased the length

       strlen_recursive(++str1);  // recursive function

     }

}

Explanation:

Here we are iterating over the loop and check if string is equal to NULL then it return the length of string otherwise it recursively count the length of string.

Following are the code in C language

#include <stdio.h>//heaader file

int strlen_recursive(char *str1) // recursive function

{

 static int l=0;// static variable  

   if(*str1==NULL)  

   {

   return(l); // return length if string is equal to null

      }

   else

   {

       l++;

       strlen_recursive(++str1); // call recursive function

    }

}

int main() // main function

{

   char str1[100]; // declaring array  

   int l=0;

    printf("Enter the string: ");

   gets(str1);// input string

    l=strlen_recursive(str1); // recursive function

printf("Total number of characters are: %d\n",l);

return 0;

}

Output:

Total number of characters are:sa

2

You might be interested in
How are computers located on a network
Luba_88 [7]

Answer:

<em>When computers connect on the same network, it is called a local area network, or LAN. </em>

Explanation:

<em>The router is given the IP address for your connection to the Internet and then assigns local IP addresses to each device in your network.</em>

<em />

<em>Hope this can help you </em>

8 0
3 years ago
Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr
klio [65]

Answer:

See the code snippet below

Explanation:

import java.util.Scanner;

public class LabProgram{

     public static void main(String[] args){

          Scanner scan = new Scanner(System.in);

          System.out.println("Please enter first number: ");

          int firstNumber = scan.nextInt();

          System.out.println("Please enter second number: ");

          int secondNumber = scan.nextInt();

          maxMagnitude(firstNumber, secondNumber);

}

     public static int maxMagnitude(int firstValue, secondValue){

         System.out.println(Math.max(firstValue, secondValue));

}

}

6 0
3 years ago
Name 3 examples of operating system software that are not Windows based.
anyanavicka [17]
Ubuntu, Linux, and Mint
4 0
3 years ago
What type of image digital image is shown here?
madreJ [45]

Answer:

soccer tournament youth league

6 0
3 years ago
Read 2 more answers
A program that allows employees to choose their starting and ending times, as long as they are at work during a specified core p
lukranit [14]

Answer:

flextimes

Explanation:

Flex times is defined as the flexible time that is scheduled for allowing the workers to alter the workday start and their finish times. This is in contrast to the traditional work arrangements which require for the employees to start work at a standard 9 a.m. and to finish at 5 p.m.

It is program which allows the employees to choose a suitable starting time as an ending time for doing their work during the specified core period.

3 0
3 years ago
Other questions:
  • what would happen if a large number of computer users are attempting to access a web site at the same time that you are
    15·2 answers
  • "The pkill command terminates _________."
    14·1 answer
  • In Windows Server 2016, what must be running to allow you to manage a server remotely with PowerShell?
    14·1 answer
  • The material placed around the ignition device to feed the flame in arson is referred to as
    8·1 answer
  • Unlike the String class where you must pass a message to an object (instance) of the class, as in x.length( ), in order to use t
    5·1 answer
  • If two different devices try to transmit to a common device at the same time, switches suffer from a problem in the collision do
    13·1 answer
  • Can anyone give me $2 (Reddem code/Promo Code)​
    15·2 answers
  • What is the correct order of the phases of the software development process?
    12·1 answer
  • Activity: Identify what hazards are addressed by the following health and safety procedures.
    8·1 answer
  • A multinational pharmaceutical company used a saffron trident in a promotional campaign for one of its drugs in India. The saffr
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!