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
algol [13]
3 years ago
13

Write an algorithm and draw flowchart to print 30 terms in the following sequence

Computers and Technology
1 answer:
valina [46]3 years ago
3 0

Answer:

/*

I don't know what language you're using, so I'll write it in javascript which is usually legible enough.

*/

console.log(buildSequence(30));

function buildSequence(maxVal){

   maxVal = Math.abs(maxVal);

   var n, list = [];

   for(n = 1; n < maxVal; n++){

       /*

        to check for odd numbers, we only need to know if the last bit

        is a 1 or 0:

       */

       if(n & 1){ // <-- note the binary &, as opposed to the logical &&

           list[list.length] = n;

       }else{

           list[list.length] = -n;

       }

   }

   return list.implode(',');

}

You might be interested in
C programming question:
denpristay [2]

Answer:

You should do this:

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL");

Explanation:

Lets consider this program and analyze the output.

int main()

{

int modelYear;

char modelName[30];

printf("enter the year");

scanf("%d",&modelYear);

printf("enter the modelname");

scanf("%s",modelName);

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL");    }

if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

This statement has a function strcmp  which is used to compare two strings.

If the user enters Extravagant as model name then this input will be compared by the string stored in modelName i.e. Extravagant, character by character. If the string entered by the user matches the string stored in modelName this means this part of the if condition evaluates to true. 0==strcmp means that both the strings should be equal.

The next part of the if statement checks if the model year entered is greater than or equal to 1999 AND less than or equal to 2002. This means that the model year should be between 1999 and 2002 (inclusive).

&& is the logical operator between both the parts of if statement which means that both should evaluate to true in order to display RECALL.

This is correct way to use because the if (modelName == "Extravagant" && modelYear >= 1999 && modelYear <= 2002)  printf("%s\n","RECALL"); statement will not display RECALL. After entering the model name and model year it will move to the next line and exit.

So in if (0==strcmp(modelName,"Extravagant") && modelYear >= 1999 && modelYear <= 2002)

printf("%s\n","RECALL"); statement when the if condition evaluates to true, then RECALL is displayed in the output.

6 0
3 years ago
What are the core scripting and coding technolies used to build ai platforms?
boyakko [2]
<span>Artificial Intelligence is a huge field. </span>
4 0
3 years ago
What can u access various sites on
Klio2033 [76]
Search engines. (I'm Misty btw if you want to know)
3 0
3 years ago
Can someone please help me...pls.. how do u delete an account on this app(brainly)..pls help fast​
Basile [38]

Explanation:

The option to delete your account can be found in your Profile Settings under Privacy. Click on the box labeled I want to delete my account, and the request will be sent for the account to be deleted.

6 0
3 years ago
Read 2 more answers
When should you use the Reply All function when replying to an email
Dmitrij [34]
When the email was sent as a group email 

5 0
3 years ago
Read 2 more answers
Other questions:
  • The ________ of the operating system enables users to communicate with the computer system. modem window network adapter card us
    14·1 answer
  • I'm the state of Florida, your first conviction for DUI can result in your vehicle being impounded for
    5·1 answer
  • On a network, which protocol is responsible for dividing files into chunks, adding headers containing information for reassembli
    10·1 answer
  • In the writing and language test of the SAT, questions ask students to do which of the following? A. Write an essay B. Define a
    14·2 answers
  • How do you check how much space is left in current drive?
    9·1 answer
  • What is it called when you remove some information from a file or remove a file from the disk ? A) save b) delete c) edit d) rem
    5·1 answer
  • The 0-1 knapsack problem is the following. A thief robbing a store finds n items. The ith item is worth vi dollars and weighs wi
    14·1 answer
  • What is the school wifi password trying to do my class work in school on different devices.
    9·1 answer
  • Which of the following is not an operating system a) boss b) window xp c) linux d) bindux​
    15·1 answer
  • One word for The characters typed by a user using a<br> keyboard.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!