Answer:
1. #include <stdio.h>
2. int main()
3. {
4. int k;
5. int j;
6. int i;
7. int array[7];
8. array[0] = 1;
9. for (i = 1; i < 9; ++i)
10. {
11. array[i] = array[i-1]*2;
12. for (j=0; j < i; ++j)
13. {
14. printf("%d ",array[j]);
15. }
16. for (k=i-2; k > -1; --k)
17. {
18. printf("%d ", array[k]);
19. }
20. printf("\n");
21. }
22. return 0;
23. }
Explanation:
- From line 1 to 3 we start the main function
- From line 4 to 7 we declare the variables that we are going to be using throughout the program including an array of 7 positions
- On line 8 we initialize the array with one to match the sequence
- From line 9 to 10 we create a for loop to create the 9 sequences of numbers
- On line 11 we assign values to the array by taking the previous value and multiplying it by 2, this way we can create the sequence 1,2,4,8,32...
- From line 12 to 15 we print the ordered array
- From line 16 to 19 we print the inverse array minus one
- On line 20 we print an enter
A) or B) not sure for sure.... Hope it helps
Answer:
// package
import java.util.*;
// class definition
class Main
{
// main method of the function
public static void main (String[] args) throws java.lang.Exception
{
try{
// initialize variables
char a='x',b='y',c='z';
// char variables with different Characters
// char a='#',b='$',c='%';
// char a='1',b='2',c='3';
// print all the combinations
System.out.print(""+a+b+c+" "+a+c+b+" "+b+a+c+" "+b+c+a+" "+c+a+b+" "+c+b+a);
}catch(Exception ex){
return;}
}
}
Explanation:
Declare and initialize variables a,b,c with "x","y","z" respectively.
Then with the help of print statement we can print all combinations
of these characters.Similarly we can check this for different input
characters.
Output:
xyz xzy yxz yzx zxy zyx
#$% #%$ $#% $%# %#$ %$#
123 132 213 231 312 321
Probably by the use of the item