tony_lynes_lab1.c - Tony Lynes Lab 1 CSCI 112#include...

Info icon This preview shows page 1. Sign up to view the full content.

/* * Tony Lynes * Lab 1, CSCI 112 */ #include <stdio.h> //** Declare function prototypes for all functions in this file**// double v1 = 0; double v2 = 0; double v3 = 0; double v4 = 0; double v5 = 0; //** This is the entry point into the program**// int main(void) {//**These are the functions we will be using to get the 5th term in the shortest way possible**// v1= get_input();//** get first input **// v2= get_input();//**get second input **// get_next(); //**use those to compute next 3**// print_result();//*Display results to the user**// } //** This functions purpose is to get two inputes from the user**// get_input() { double q; //** We must use a double since we are allowing all real numbers. q is not a symbol, random letter **// printf("Please enter a number: (XX.XX)> ");//**This printf statement is asking for the user to enter a number up to 2 decimal places**//
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: scanf("%lf", &q);//** takes in input as a leading float**// printf("You entered %.2f\n", q);//** We now present what the user entered, up to 2 decimal places and it is stored as double "q"**// return q; //** returns the value q to the user **// } get_next(void)//** This function's purpose is to use the values taken by the user, and plug them into the next 3 sequences to get the 5th one**// { v3= ( v1/2 ) + ( 3 * v2 );//This is the equation used, given by the instructor.**// v4= ( v2/2 ) + ( 3 * v3 ); v5= ( v3/2 ) + ( 3 * v4 ); } print_result(void)//**This function will take the results of the get_next function and display the 5th term, which is what we want**// { printf("The result is %.2f", v5);//** We are printing our pre defined input f up to two decimal places. This is out 5th term**// }...
View Full Document

  • Spring '14
  • Rafal A. Angryk
  • Set Theory, Decimal

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern