Tuesday, June 16, 2020

My C code to calculate market capitalization of a stock

This is like the 5th or 6th C program I've written.  It asks a user for the 1. shares outstanding and 2. the stock price, and then it restates what it asked and what the user answered, and then it calculates and prints out "Market Cap is ..."

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

int main(void)

{

    int sharesout = get_int("what are the shares outstanding?\n");
    int stockprice = get_int("what is stock price?\n");

    printf("Shares Outstanding are %d\n ", sharesout);
    printf("Stock price is %d\n", stockprice);
    
    int mktcap = sharesout * stockprice;

    printf("the market cap is %d\n", mktcap);



}

No comments:

Post a Comment