'use of undeclared identifier - cs50 problem set [duplicate]

I am new to programming in general and especially to c. I am a bit confused as to why I get this error when trying to run the following code. It should be noted that I have some code before this but this is the part that is giving me some problems. This is the part that seem to be giving me some problems:

#include <cs50.h>
#include <stdio.h>


    int a;

    do
    {
        int a = get_int("How many cents: ");
    }
    while(a < 0)
    return a;

The exact error message is:

Pset1/cash/ $ make cash
cash.c:44:13: error: declaration shadows a local variable [-Werror,-Wshadow]
        int a = get_int("How many cents: ");
            ^
cash.c:40:9: note: previous declaration is here
    int a;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make: *** [<builtin>: cash] Error 1


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source