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
vaieri [72.5K]
3 years ago
10

Write a function that takes a character string value and prints out the bytes stored in memory of its representation (including

the terminating 0). Test it on a string containing your full name.
Computers and Technology
1 answer:
Goryan [66]3 years ago
6 0

Answer:

C++ code explained below

Explanation:

SOURCE CODE:

*Please follow the comments to better understand the code.

#include <stdio.h>

int numOfBytes(char* string)

{

// initialise the variables

int i=0,size=0;

// while the string reaches to \0, repeat the loop.

while(string[i]!='\0')

{

// add that size

size += sizeof(*string);

 

// increase the i value.

i++;

}

// add 1 byte for \0

size = size+1;

return size;

}

int main() {

char name[]="Praveen Kumar Reddy";

printf("The size is %d bytes.",numOfBytes(name));

 

  return 0;

}

=============

You might be interested in
Unanswered questionl
antoniya [11.8K]

¿ ? ¿ ? Whattttt ? ¿ ? ¿

3 0
3 years ago
What should we do to protect data
puteri [66]
Six Easy Steps You Can Take To Protect Your Data Online
Protect Passwords. Lock your phone with a strong password and fingerprint or Touch ID. ...
Turn off Lock Screen Notifications. ...
Lock Your Apps. ...
Hide Your Photos. ...
Use A Private Number. ...
Keep Your Browsing Secret.
3 0
3 years ago
Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
Furkat [3]

Answer:

The solution code is written in Python 3

  1. import random
  2. import string
  3. def simulate_several_key_strikes(l):
  4.    char_set = string.ascii_lowercase
  5.    return ''.join(random.choice(char_set) for i in range(l))
  6. print (simulate_several_key_strikes(10))

Explanation:

The program is aimed to generate random characters and the number of characters generated is dependent on user input. Hence, we will need to import the random module (Line 1). We also import string module so that we can make use of its associated method to generate English letters (Line 2)

Next, we create the function simulate_several_key_strikes that takes one single parameter, l, as input. Within the function body, we use ascii_lowercase method to generate the lowercase letter set and assign it to char_set variable (Line 5). We use random.choice method to randomly pick one of the letter in char_set and join it with an empty string (Line 6). Please note there is a for-loop that will repeatedly generate l-number of character and eventually return it as output.

We test the function by passing 10 as input parameter and we shall get a sample output as follows:

xuiczuskoj

7 0
3 years ago
How do you change your age on here? I accidentally put that i was 15 but i am only 13. How do I change this?
oksano4ka [1.4K]
I honestly don't think they can or just change your account from what I know of I just tried just now to see for you. I think you jus gotta leave it lol. I'm 13 too I lit myself 16
5 0
3 years ago
Harlequin frogs are an endangered species that live in a small area of Costa Rica. The reasons for the species' decline is unkno
Damm [24]

Answer:

<u>a. The scientists must be careful of how many variables they include in their simulation so they do not cause further harm to the frogs.</u>

Explanation:

It is not statistically accurate to assume that the number of variables included in the simulation would cause further harm to the frogs because we need to <em>remember </em>that a simulation is simply a computerized imitation of a real situation, which is usually not totally alike with a real process.

So in no way from a statistical standpoint, does the scientists' decision on the number of variables causes direct harm to the frogs.

3 0
3 years ago
Other questions:
  • Fiber deployment architectures include all of the following except:
    7·2 answers
  • Write code to print the location of any alphabetic character in the 2-character string passCode. Each alphabetic character detec
    8·1 answer
  • Sql statements that define the objects such as tables, indexes, triggers, etc. in a database are referred to as _______________
    7·1 answer
  • While editing a film, a director feels that the actors have not enacted a particular scene well. What type of shot must the dire
    12·1 answer
  • Next, Sue decides to embed a chart from Microsoft Word. She copies and pastes data from a table that she has already created in
    8·1 answer
  • A device that allows multiple computers to communicate with each other is
    9·1 answer
  • Explain the different type of shift register counter ​
    14·1 answer
  • I'll mark you the brainlest please help
    14·2 answers
  • How does a python programmer concatenate a numeric value to a string value?
    7·1 answer
  • Which characters are used in hump notion?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!