public class Practiceseven // Class declaration
{
public static void main(String[] args) //main method
declaration which means execution first starts here
{
int[] array = { 4,6,2,8,10 }; // array intialisation and
declaration
printArray(array); // calling printArray method
int number=5; // declaring temp variable for swapping
swap(array,number); // calling swap method
printArray(array); //calling printArray method
}
static void printArray(int[] array) //method declaraton
{
System.out.print("the values in array are:");
for(int i=0;i<array.length;i++) //checking and sending array
elements one by one for printing
{
System.out.print(array[i] +" "); //printing array.
}
System.out.println("]");
}
static void swap(int[] integers,int num) //swap method
declaration
{
if(integers.length>0) //checking array length and comparing with
0
{
integers[0]=num; //replacing element in array(0) location to 'num'
value
}
num=0;
}
}
output:-
This program is for printing
the values in the array and with the swap function.
==>Arrays are contigious memory locations which stores values in memory locations continiously one by one.Memory locations in array start from array(0) to increasing manner. Whenever we want to retrieve the values we can retrieve that by using the memory locations.
-==> Swapping is a function or method which is used to replace a number using temperory variable.
-->Here in this program temp variable is 'number',It is being swapped by the array elements this causes value in the will be replaced with this value.
In this program we are initialised and declared an array with some elements and also a swap method.
-> First we are printing the array as it is with the declared elements in the printArray method it first prints the message which is given and the it checks the length of the array and values and send those values for printing.
-->In the swap method it first checks the length of the array if the length is greater than 0 then this method swaps the the element in the 0th location with the 'num' value, other wise replace with '0'.
Show what is printed on the screen when this program is executed. Show work for partial...
What is printed when the following code is executed? #include <stdio.h> int main() { for (int i=3, j=5; i>=0; i-=2, j+=j*i) { printf("%d", j); منم }
5. (7 pts) What wil display on the output screen after following program is executed? includeciostream using namespace std int b 40 int A function(int a) int main (void) int c 7, b 15 cout<cA function (e) <cendla return 6 int A function (int a) int i cout<<b<<endl; if (a>-0) else return i i-ai i--ai Ans5 6. (7 pts) Show what will appear on the output screen after the following program is executed tincludeciostream> using namespace std; void A function...
MICROSOFT VISUAL STUDIO C++:
13. What will be printed when the following statements are executed? int x = 0, y = 0; do { if(x == y) x= x + 1; else y=y — 1; } while (x<y + 4); cout << “y=“ <<y <<“ X=" << x << endl;
[10pts] 7) What is the output of the following program? In other words, what is printed to the screen when you run it? #include <iostream> #include <queue> using namespace std int main) char qu[5] ('a, 'b',c'd','e' queue <char> q int N = 4; char ch for(int í - 0:ì < 5;++1) q.push(qu (]) for (int ǐ 0;i < N;++i) { = ch q.front); q push(ch): q.pop while(!q.emptyO) f cout << q.front ) <<endl; q.pop )
When using Python, what exactly is printed when the following program is run? counter = 4 sum = 0 while counter < 7: sum = sum + 2 counter = counter + 1 print ("Value is", sum)
Show all work for the following problems answers only. partial credit will be given for work clearly shown. NO CREDIT will be given for .... . (10 points) If 1.000 g of chromium metal produces 1.461 g of chromium oxide, what is the empirical formula of the product?
What type of address is printed by following program
Question 15 What type of address is printed by the following program: include <stdio.ho int maino int x; printf("Xp\n", & x); return ; Virtual Physical Dynamic Heap
CREDIT Show all work for partial credit. 1) How much heat energy is released when 1000. g of methane gas (CH4) is completely reacted with excess O2 according to the following equation? (up to 8 pts) Hint: you will need to convert from g- mol energy CH& Cg)+202 (g) CO2 (g ) + 2 H20 (I)+890.4 kJ
7. QuickBooks allows users to setup different ‘on-screen’ and ‘printed’ versions of sales forms. a. True b. False 8. Which of the following forms can price levels not be used on? a. Invoice b. Bill c. Sales Receipt d. Credit Memo e. None of the above 9. A customer has 3 outstanding jobs and makes a partial payment. In QuickBooks, that payment: a. Must be applied to the first job taken on for that customer b. Must be applied to...
Java programming. 1. When your program executes a throw statement, which statement is executed next?