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
Naya [18.7K]
3 years ago
13

Read an integer number from the user. If the number is not positive, change its sign. Create the algorithms for the following ta

sks: 1 Count the digits of the number 2 Count the odd digits of the number 3 Calculate the sum of the digit values of the number
Computers and Technology
1 answer:
atroni [7]3 years ago
3 0

Answer:

ALGORITHM READ_NUMBER()

1.       SET NUM := 0 [INITIALLY SET THE VALUE OF NUM TO 0]

2.       WRITE : “Input a Number” [DISPLAY A MESSAGETO USER]

3. READ NUM [STORE THE VALUE TO NUM]

4.       IF NUM<0 [IF VALUE OF NUM IS -VE THEN MULTIPLY IT BY -1]

5.       NUM := NUM * (-1)

6.       [END OF IF]

7.       RETURN NUM [RETURN THE NUMBER]

1. ALGORITHM DIGIT_COUNT(NUM)

SET COUNT := 0

SET R:=0

REPEAT WHILE(NUM != 0)

R := NUM MOD 10

COUNT : = COUNT+1

NUM := NUM/10

[END OF LOOP]

RETURN COUNT

2. ALGORITHM DIGIT_ODDCOUNT(NUM)

SET COUNT := 0

SET R:=0

REPEAT WHILE(NUM != 0)

R := NUM MOD 10

IF (R MOD 2 != 0)

COUNT : = COUNT+1

[END OF IF]

NUM := NUM/10

[END OF LOOP]

RETURN COUNT

3. ALGORITHM SUM_OF_DIGITS(NUM)

SET SUM := 0

SET R:=0

REPEAT WHILE(NUM != 0)

R := NUM MOD 10

SUM : = SUM+R

NUM := NUM/10

[END OF LOOP]

RETURN SUM

C++ PROGRAM

#include<iostream>

using namespace std;

//method to count the number of digits

int digit_count(int num)

{

   int count=0; //set count to 0

   int r;

   //loop will continue till number !=0

   while(num!=0)

   {

      r=num%10; //find the individual digits

      count++; //increase the count

      num=num/10; //reduce the number

  }

  return count; //return the count

}

int odd_digit_count(int num)

{

   int count=0;//set count to 0

   int r;

   //loop will continue till number !=0

   while(num!=0)

   {

      r=num%10;//find the individual digits

      if(r%2!=0) //check for odd digits

      count++;//increase the count

      num=num/10;//reduce the number

  }

  return count;//return the count

}

int sum_of_digits(int num)

{

   int sum=0;

   int r;

   //loop will continue till number !=0

   while(num!=0)

   {

      r=num%10;//find the individual digits

      sum=sum+r;//find the sum of digits

      num=num/10;//reduce the number

  }

  return sum;//return sum

}

//input method

int input()

{

  int x;

  cout<<endl<<"Enter a number";

  cin>>x;//read the number

  if(x<0) //if -ve then turn it to +ve

  x=x*-1;

  return x; //return the number

}

//driver program

int main()

{

  int n,dc,odc,sod;

  n=input(); //call to input()

  dc=digit_count(n); //call to digit_count()

  odc=odd_digit_count(n); //call to odd_digit_count()

  sod=sum_of_digits(n);//call to sum_of_digits()

  //display the details

  cout<<endl<<"The positive number is : "<<n;

  cout<<endl<<"The number of digits in "<<n<<" is "<<dc;

  cout<<endl<<"The number of odd digits in "<<n<<" is "<<odc;

  cout<<endl<<"The sum of digits of "<<n<<" is "<<sod;

}

Explanation:

You might be interested in
"what is the problem with using challenge handshake authentication protocol (chap) as an authentication protocol?"
Alexxandr [17]

Its use of the message digest 5 (MD5) hash algorithm for security.

CHAP uses a combination of MD5 hashing and a challenge-response mechanism, and authenticates without sending passwords as plaintext over the network. The security of the MD5 hash function is severely compromised.

5 0
4 years ago
Most of the Desktop games contain a backdoor used to test and update the game.
sveta [45]

A backdoor is a typically covert method of bypassing normal authentication or encryption in a computer, product, embedded device (e.g. a home router), or its embodiment (e.g. part of a cryptosystem, algorithm, chipset, or even a "homunculus computer" —a tiny computer-within-a-computer such as that found in Intel's AMT technology).Backdoors are most often used for securing remote access to a computer, or obtaining access to plaintext in cryptographic systems. From there it may be used to gain access to privileged information like passwords, corrupt or delete data on hard drives, or transfer information within autoschediastic networks.

the answer is True

i hope it will help you

8 0
3 years ago
Different network scenarios require the
Vladimir [108]

Answer:

a) Viruses

Explanation:

Vulnerability assessment is performed by variety of tools and these can be protocol analyzer, vulnerability scanner, Honeypots, port scanners, honey nets and banner grabbing tools.

Port scanners : they are used to scan the ports which can be exploited by attackers. Most of TCP/IP applications communicate using different ports and attackers can exploit these ports if they are found vulnerable. for example : ports like 80 and 443 are commonly used for HTTP and SSL communication. 22 is used for SSH and if they are open to world then it will allow attackers to use those to get the entry into the system.

Protocol Analyzers : They are used to analyze the packet captures. tools like wireshark, tshark, these tools will help user to decode HTTP/SSL/HTTPS/FTP/RSTP or any application protocols communication. this will help user to understand any unwanted or non-anticipated traffic.

Vulnerability Scanners : They are used to detect the vulnerabilities in the network or systems. these will help administrators to get the alerts whenever there are unanticipated activity. It will have two types of scanners one is active scanner and other is passive scanner. Active scanners will keep on sending probes at the fixed time slots and passibe scanners will be in listening mode all the time. These scanners will alert when a new nodes comes up or goes down or if any system gets compromised.

Honeypots and Honey nets : They are devices or softwares which are having limited security. These devices are made vulnerable purposefully so that attackers can try and attack.  This will help softwares to detect the attackers when they try to exploit these open vulnerabilities. They are deceptions created with purpose.

Banner grabbing Tools : These are tools which will capture the banner information like HTTP protocol version, underlying operating system, open ssl versions being used, server software and similar information. these are important as it will open up potential vulnerabilities in the underlying software. for ex : SSLv3 has a vulnerability known to world and can be exploited by anyone.

4 0
3 years ago
What is a different paragph formatting tools
soldi70 [24.7K]
You can have paragraph alignment which is left, right, and center
5 0
4 years ago
What is a system of computers that are joined together and connect to peripheral devices and can’t be accessed from home
harina [27]
<span>What is a system of computers that are joined together and connect to peripheral devices and can’t be accessed from home = LAN for Local Area Network, unless it's connected to the internet and you allow VPN/RAS system access you will not be able to connect to a LAN remotely.</span>
7 0
4 years ago
Other questions:
  • Which sentence best describes an activity stream?
    10·2 answers
  • Which piece of personal information do websites often require users to enter?
    6·2 answers
  • Describe Ms word environment.​
    14·1 answer
  • Assume you're running a query on your orders in the past year. You want to see how many orders were placed after May. What type
    5·1 answer
  • Managing your calendar and emails can be easily accomplished through ___ software
    8·1 answer
  • Please find one organization that has recently adopted virtualization and summarize their reasons for taking this approach. What
    12·1 answer
  • The add_prices function returns the total price of all of the groceries in the dictionary. Fill in the blanks to complete this f
    15·1 answer
  • What is the importance of different camera angles ?
    9·2 answers
  • PLS REPLY ASAP WILL MARK BRAINLIEST
    5·2 answers
  • After data is collected, how is it analyzed?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!