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
Natalija [7]
3 years ago
14

Write a recursive function called firstOccurence that will return the position of the first occurence of a character within a st

ring B.) Write a recursive function called sumAscii that will return the sum all of the chars within a string. For B the sum of the chars is their ASCII equivalent value. For instance the character 'A' has a value of 65.
Computers and Technology
1 answer:
patriot [66]3 years ago
6 0

Answer:

C++ code is explained below

Explanation:

a- C++ code:

#include<iostream>

using namespace std;

#include <string.h>

int firstOccurence(char *s,char c) //recursive function

{

static int i;

if(!s[i])

{

return -1;

  }

  else

  {

      if(s[i]==c)

      return i;

      i++;

      firstOccurence(s,c);

  } }

int main()

{

char s[1000],c;

int n;

printf("Enter the string : "); //tales input

gets(s);

printf("Enter character to be searched: "); //takes input a character to be searched

c=getchar();

n=firstOccurence(s,c); //call function

if(n>-1)

   printf("character %c is first occurrence at location:%d ",c,n);

else

printf("character is not in the string ");

return 0;

}

b- C++ Code- This program takes a string and display sum of all characters in a string.

#include<iostream>

using namespace std;

int sumAscii(string s) //recursive function

{

int sum = 0;

if(s.length() == 0)

{

exit(0);

}

for (unsigned int i = 0; i < s.size(); i++)

{

sum += s[i];

}

return sum;

}

int main () //main function

{

cout << "This word adds up to " << sumAscii("CAT") << " in ASCII " << endl;

return 0;

}

You might be interested in
Many of today’s digital devices operate on battery power supplied by what kind of ion batteries.
stich3 [128]
"Lithium ion" is used in your cellphone.
6 0
3 years ago
School computer labs are used often to teach technology skills or subject-specific skills ____ the rest of the curriculum.
Lyrx [107]
The answer that best fits the blank is ISOLATED FROM. Those technology skills and subject-specific skills that are separated from the rest of the curriculum are being taught using the school computer laboratories. Technology skills include skills that use computers or machines such as web design, email management, database and spreadsheets, and etc.
8 0
4 years ago
Viktor has climbed a tall tree to get a good view of the giraffes on the savannah. He is snapping lots of photographs of the gir
igomit [66]

Answer: C. a good vantage point

3 0
3 years ago
A married man gets a new job in a company. After three months, he meets a younger woman in the finance department and they begin
pav-90 [236]

Answer:

False ( B )

Explanation:

Of  the seven IT  infrastructure domains The USER domain was not at risk because the User Domain is not task with handling the sharing of data or Mutual communication between users in a Typical IT infrastructure.

The domain charged with such responsibility is The LAN domain because the LAN domain is charged with the sharing of information between the USERS and maintaining good mutual communication, and since the relationship has become sour, the sharing of information between the users will suffer the most and it will be at a high risk

5 0
3 years ago
A ____ is an electronic device, operating under the control of instructions stored in its own memory, that can accept data, proc
taurus [48]

Answer:

Server

Explanation:

- it is an electronic device

- under control of another computer or human

- stored instructions as code

- accepts data from external source

- process the data it gets, for example filtering the data or modifying it

- produces information, for example AI created suggestions

- Stores Information on storage drives

6 0
3 years ago
Read 2 more answers
Other questions:
  • Which sentences in the passage show the preventive measures to avoid data breach?
    9·1 answer
  • WILL UPVOTE &lt;3
    9·1 answer
  • Which DHCPv4 message will a client send to accept an IPv4 address that is offered by a DHCP server? (Points : 5) Unicast DHCPACK
    8·1 answer
  • 1.) Florida has ____________ roads that are designated as part of the National Highway System.
    12·1 answer
  • A ________ is a question you ask about data stored in a database
    9·1 answer
  • Which line of code outputs the decimal portion of a float stored in the variable x? print (x % 1000) print (x) O print (x / 1000
    13·1 answer
  • Which of the examples is part of client-side code?
    12·1 answer
  • I will give Brainliest and Extra points for correct answers!!!
    13·2 answers
  • Which class members should be declared as public?
    12·1 answer
  • Would you consider upgrading Maxine’s wardrobe a need or a want?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!