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
wariber [46]
3 years ago
7

2-Write test programs in java to determine the scope of a variable declared in a for statement. Specifically, the code must dete

rmine whether such a variable is visible after the body of the for statement

Computers and Technology
1 answer:
ankoles [38]3 years ago
7 0

Answer:

See Explaination

Explanation:

public class testscope

{

//start of main function

public static void main(String[] args)

{

//varible declration

int i;

int x;

//loop for 10 times

for(i=0; i<10; i++)

{

//initialize value of x to 10

x = 10;

}

//the scope of variable x is visible outside of for loop

System.out.println("The value of x is: "+x);

}

}

See attachment for sample output

nb:

You can clearly see in the output of Java program the value of x is not printed and program return errors. It means the variable x declared inside for loop does not has scope outside the for loop.

You might be interested in
Without a/an ________. a computer is useless
Len [333]
Without a/an Operating system. a computer is useless
3 0
3 years ago
________ is a markup language that allows for tagging selected elements of the content of documents for their meanings and is us
trasher [3.6K]

Answer:

E)nXML

Explanation:

XML is a short for Extensible Markup Language. It is a markup language like the Hypertext markup language (HTML) and are both used in the development of web applications. However while the HTML describes the content of the Web page that is the graphics, images and videos and how they are displayed, the XML handles the description of data and information formats, their storage and the transportation and sharing over the internet.

4 0
3 years ago
Read 2 more answers
What changes do you need to make to the algorithm to take as first input the numbers to be compared
Alenkinab [10]

Answer:

Explanation:

The constant function is useful in algorithm analysis, because it characterizes the number of steps needed to do a basic operation on a computer, like adding two numbers, assigning a value to some variable, or comparing two numbers. Executing one instruction a fixed number of times also needs constant time only.

6 0
3 years ago
Each generation is set apart from the previous generation because of an innovation.
ehidna [41]

Answer:

Second Generation: transistors

Third Generation: integrated circuits

First Generation: vacuum tubes

Explanation:

Generations of computers are categorized based on the technologies that were used in them.

Given innovations or technologies are:

<u>transistors :</u>

Transistors were introduced in the second generation in place of vacuum tubes.

<u>integrated circuits :</u>

Integrated circuits were introduced in the third generation. An IC consists of multiple transistors.

<u>vacuum tubes:</u>

The very first generation of computers used vacuum tubes to do the calculations. the only drawback was that the tubes used to heat up very soon.

Hence,

Second Generation: transistors

Third Generation: integrated circuits

First Generation: vacuum tubes

3 0
3 years ago
Write a program that removes all spaces from the given input.
sasho [114]

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

char *removestring(char str[80])

{

   int i,j,len;

   len = strlen(str);

   for( i = 0; i < len; i++)

   {

       if (str[i] == ' ')

       {

           for (j = i; j < len; j++)

               str[j] = str[j+1];

           len--;

       }

   }

   return str;

}

int main ()

{  

char  str[80];

   cout << "Enter a string : ";

   cin.getline(str, 80);

   strcpy(removestring(str), str);

   cout << "Resultant string : " << str;

   return 0;

}

In this program the input is obtained as an character array using getline(). Then it is passed to the user-defined function, then each character is analyzed and if space is found, then it is not copied.

C++ does not allow to return character array. So Character pointer is returned and the content is copied to the character array using "strcpy()". This is a built in function to copy pointer to array.

5 0
3 years ago
Other questions:
  • A document that promises to pay specified sums of money on specified dates and is a debt to the issuer is called
    14·1 answer
  • Device that converts sound into electrical signals, which are sent to the computer or other recording device
    6·1 answer
  • What five safety habits are you using for the internet?
    12·1 answer
  • The keyboard and the mouse____ parts of a computer ​
    8·1 answer
  • At the frequency of 2.4 GHz what is the free-space path loss in dB.
    9·1 answer
  • If an interest inventory reveals that you are highly interested in solitary, introverted work, what might be the best type of ca
    9·2 answers
  • Define networks, marketplaces, and platforms and discuss their differences.
    15·1 answer
  • What is a characteristic of high-level languages?
    15·1 answer
  • How to get the lightning round in dares of eternity
    5·1 answer
  • If a preferred (faster) learned route over a WAN has administrative distance 110 that competes with a static backup (slower) rou
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!