〜ことか
How…! (exclamation)machine translation
FormationQuestion word (どんなに・何度・どれだけ…) + plain form + ことか
〜ことか is an exclamatory sentence emphasizing degree — "how much, how very": どんなにうれしかったことか (how happy I was!). Although it ends in か, this is not a question — the speaker is simply exclaiming that the degree is beyond measure.
The point you must remember: the clause is always preceded by a QUESTION WORD such as どんなに (how much), 何度・何回 (how many times), どれだけ (to what extent). Without the question word the sentence doesn't work: you must say どんなに心配したことか, not 心配したことか.
Connection: question word + plain form + ことか; the more polite versions are ことでしょう/ことだろう. This pattern works in both speech and writing, and usually recounts feelings that have built up over a long time — which is why the preceding clause is often in the past tense.
Examples
合格の知らせを聞いて、どんなにうれしかったことか。
When I heard the news that I had passed, how happy I was!
同じ間違いを何度注意したことか。
How many times have I had to point out the same mistake!
母にどれだけ助けられたことか。
How much my mother has helped me!