• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #495
    admin
    Keymaster

      First step is to accept credit card from the user by creating a new function, which in the below case is enterccno.

      This function is of type long (since 13-digit or more and int will not fit into the memory). It will take void as argument as the function will not initially take any particular long value as input to begin with.

      cs50 credit card problem

       

      
      
      #include <stdio.h>
      #include <cs50.h>
      
      long enterccno (void);//long type as 14-digit credit card will not fit into the memory as int type
      
      int main(void)
      {
          long y = enterccno ();
          printf("credit card no. entered is %ld",y);
      }
      
      long enterccno (void) //It will take void as argument as the function will not initially take any particular long value as input to begin with.
      {
          long x = get_long("enter creditcardno");//get_long function by cs50.h leveraged to accept input of creditcard no. from user.
          return x;//stored x value or entered creditcardno transferred inside the main function when entercccno function called.
      }

      [learn_press_profile]

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top