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
It is ethical to use ICT in early years
Dahasolnce [82]
Early years of what? ICT is generally ethical as it’s just stressing unified communications of different telecommunications/IT devices
3 0
3 years ago
Which of the following is true about the Purpose of the Page and the Page Quality (PQ) rating? Select all that apply. True False
aleksandr82 [10.1K]

Answer:

Explanation:

Harmful or malicious pages should always get a page quality (PQ) rating of Lowest. True

Pages with an informational or educational purpose should always be given higher page quality (PQ) ratings than entertainment or gossip pages. False

There is no relationship between the purpose of the page and the page quality (PQ) rating. False

If you cannot determine the purpose of the page after extensive effort, the page quality (PQ) rating should be Lowest. True

7 0
3 years ago
The unique identifier for each record in a database table is called the
nadya68 [22]
The answer is C. Primary Key. I hope this helps
5 0
3 years ago
Need answer ASAP.
Sladkaya [172]

Answer:hi I need help with

Explanation:

3 0
3 years ago
The computerization of the layout and paste-up process further complicated printing, as did the digitizing of photographs.
andrey2020 [161]

Answer:

The computerization of the layout and paste-up process further complicated printing, as did the digitizing of photographs.

b. False

Explanation:

It is false as computerization has simplified, as in many other instances paste up or laying out methods instead, because the printing steps are now fewer and strightforwarder thanks to the desktop standardized creative page-design publishing programs.

Previously, printing laid on the offset lithography process, which first needed a completed page or "camera-ready page", known as mechanicals or mechanical art firts, to be them sent to be photographed using a specialized camera to get a same-size film negative for each printing plate designed.

Paste up also depended on a several steps process called phototypesetting. First you needed to obtain what was called a "cold type" printed on photographic paper shaped in long columns of text which turn ot to be a single column in a scroll of narrow (3-inch or 4-inch) printouts, as deep as the text was. There were crafted people, known as paste-up artist, layout artist, mechanical artist, production artist, or compositor who, after receiving the types from the typesetter, trimmed them carefully into sections and sequenced them along the necessary columns, so he did with headlines and all the other designed typographic to get the final page design to be printed.   The result were series of strips that were sticked out using rubber cement as a partial glue on the back applied using a brush or passing them through a machine that would apply an adhesive type of wax, so thatthe strips were removable if they needed to be changed on a stiff white paper-board, the artist managed to set them in publication's margins and columns, using a pencil, non-photographic blue ink or a light cyan color which the orthochromatic film would ignore in the printing plates of offset lithography.

Digital photography with its better image exposure, contrast, color correction image output as well, has developed fast from traditional darkroom methods to continuous-tone digital printers and quality computer processing of superior images obtained from a digital camera or from scanned conventional film directly to digital color printers, compared to conventional darkroom prints, when evaluated for resolution, image quality, costs, chemical-free digital photography.

7 0
3 years ago
Other questions:
  • To create an identical version of a slide you would click
    6·2 answers
  • 2 The software needed to send an email is:
    7·1 answer
  • A program uses two classes: dog and poodle. which class is the base class and which is the derived class?
    7·2 answers
  • If you receive an email message you suspect is spam, what should you do?
    11·1 answer
  • Write a for loop that prints the values 1 2 4 8 16 32 64 by increasing the value of a counting variable by a factor of two in ea
    15·1 answer
  • Unchecked exceptions require you surround the code that might throw such an exception with a try block or you must use a throws
    5·1 answer
  • What is the name for the size and style of text?
    8·2 answers
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • UPS or FedEx plays what role in the supply?
    9·1 answer
  • Give a real-world example of a selection control structure.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!