Answer:
See explaination for the program code
Explanation:
code:
public static int[] countLastDigits(int[] list) {
int[] count = new int[10];
for (int i = 0; i < list.length; i++) {
int digit = list[i] % 10;
count[digit]++;
}
return count;
}
<span>C. proofread her work carefully, ask a coworker to look it over, and correct all mistakes
</span>
Answer:
I get 0x55 and this the linking address of the main function.
use this function to see changes:
/* bar6.c */
#include <stdio.h>
char main1;
void p2()
{
printf("0x%X\n", main1);
}
Output is probably 0x0
you can use your original bar6.c with updaated foo.c
char main;
int main() // error because main is already declared
{
p2();
//printf("Main address is 0x%x\n",main);
return 0;
}
Will give u an error
again
int main()
{
char ch = main;
p2(); //some value
printf("Main address is 0x%x\n",main); //some 8 digit number not what printed in p2()
printf("Char value is 0x%x\n",ch); //last two digit of previous line output
return 0;
}
So the pain in P2() gets the linking address of the main function and it is different from address of the function main.
Now char main (uninitialized) in another compilation unit fools the compiler by memory-mapping a function pointer on a char directly, without any conversion: that's undefined behavior. Try char main=12; you'll get a multiply defined symbol main...
Explanation:
Answer:
// here is code in java.
public class NAMES
{
// main method
public static void main(String[] args)
{
int n=4;
// print the upper half
for(int a=1;a<=n;a++)
{
for(int b=1;b<=n-a;b++)
{
// print the spaces
System.out.print(" ");
}
// print the * of upper half
for(int x=1;x<=a*2-1;x++)
{
// print the *
System.out.print("*");
}
// print newline
System.out.println();
}
// print the lower half
for(int y=n-1;y>0;y--)
{
for(int z=1;z<=n-y;z++)
{
// print the spaces
System.out.print(" ");
}
for(int m=1;m<=y*2-1;m++)
{
// print the *
System.out.print("*");
}
// print newline
System.out.println();
}
}
}
Explanation:
Declare a variable "n" and initialize it with 4. First print the spaces (" ") of the upper half with the help of nested for loop.Then print the "*" of the upper half with for loop. Similarly print the lower half in revers order. This will print the required shape.
Output:
*
***
*****
*******
*****
***
*