Skip to content

C program punt pass and kick compilation…

February 19, 2014

A simple C program to demonstrate how one might create a punt, pass and kick application for their local YMCA.  This is a prototype, a proof of concept really.  This program demos the following good program design principles

Structures programming – using functions to separate the program logic

loops – to avoid repeated code

variables – declare locally

parameters – passing simple data among functions

#include “stdlib.h”

//function prototying
int get_punt();
int get_pass();
int get_kick();
int process(int,int,int);
void print_results(int);

int main(){

int i, punt, pass, kick, total;

printf(“\n\nMain Menu\n\n”);


printf("Enter a punt distance\n\n");
punt = get_punt(); //call function, store result
}else if(i==2){
printf("Enter a pass distance\n\n");
pass = get_pass();
}else if(i==3){
printf("Enter a kick distance\n\n");
kick = get_kick();
}//end if

}//end for

printf("\ndone getting scores….. processing ………\n\n");

total = process(punt,pass,kick);//call function, passing in score data, store result

print_results(total);//call function, passing total


void print_results(int total){
printf("\n\nThe total distance of the punt, pass and kick is %d :", total);

int process(int punt, int pass, int kick){
int total = punt + pass + kick;
return total;

int get_punt(){
int punt;
scanf("%d",&punt); // get input from keyboard – store to locally defined variable
return punt;

int get_pass(){
int pass;
return pass;

int get_kick(){
int kick;
return kick;


From → C programming

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: