You don't have the indentation right in the for-loop section of your code, which I think is making it harder for you to see what's wrong. Here's that section, with proper indentation.
for (int i = 0; i <= n; i++)
for (int j = 0; j <= i ; j++)
for (int k = 0; k <= j ; k++)
Answer to question 2: So in the j loop in your code, you're printing one ".", then going into the k loop to print some "#", then going back to the j loop to print another one ".", then going into the k loop to print more "#", and so on until you're done with the j loop, and print the newline in the i loop.
"What is the logic behind for generating the pyramid?" That's what you're going to have to figure out. It looks like you're working on the "Right-Aligning with Dots" step of the problem. Does your code from the "Building the Opposite" step work correctly? If it does, leave the section of your code where you print the "#" alone, and add another section where you print periods right before it. If you don't have the "Building the Opposite" step working, go back to the first step you do have working.
Something that's a good idea to practice is doing the steps of your code yourself. You would take a piece of paper, and go through each line of your code, keeping track of what the variables are, and doing what your code says. This helps understand how things like loops work, and makes writing code easier in the future.
A couple other comments on your code:
It looks like you're going to have "off by one" errors. If n = 4, you should be printing exactly 4 lines, but
for (int i = 0; i <= n; i++) this line of code will have you printing 5 lines. Generally, loops like that are written with the middle being
i < n (no equals sign). You should go through the loop yourself to see how that works.
Also, it doesn't look like the section where you get the user input will work right with bad input. Try looking at the notes on the website to see how a do-while loop should look.