User Tools

Site Tools


user:psechris:portfolio:cprogproject3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
user:psechris:portfolio:cprogproject3 [2013/02/20 15:23] – [Code] psechrisuser:psechris:portfolio:cprogproject3 [2013/03/05 05:43] (current) psechris
Line 1: Line 1:
 +======Project: Adder======
  
 +A project for C/C++ by Paul Sechrist during the Spring 2013.
 +
 +=====Objectives=====
 +1. C program must return the sum of two integer arguments
 +
 +=====Prerequisites=====
 +In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:
 +
 +  * command line interpreters
 +  * execution environments
 +  * arguments & parameters
 +  * data types & memory
 +  * operations & functions
 +  * pointers
 +  * arrays
 +
 +=====Background=====
 +An adder project similar to the major in class project from CSCS 1240 Problem Solving. However now the programming is in C/C++ rather than VBS.
 +
 +
 +=====Code=====
 +
 +<code c 1>
 +#include <stdio.h>
 +#include <stdlib.h>
 +
 +
 +int main() 
 +{
 + unsigned char b;
 + unsigned char a;
 +
 +
 +
 + fprintf(stdout, "Enter first integer: \n");
 + fscanf(stdin, "%hhu", &a);
 + fprintf(stdout, "Enter second integer: \n");
 + fscanf(stdin, "%hhu", &b);
 + unsigned char ans = (a+b);
 + fprintf(stdout, "Your answer for %hhu plus %hhu is: %hhu", a, b, ans);
 +
 + return 0;
 +}
 +</code>
 +=====Execution=====
 +
 +<cli>
 +E:\CCC\CSCS1320\Joe>week2project
 +Enter first integer:
 +1
 +Enter second integer:
 +1
 +Your answer for 1 plus 1 is: 2
 +E:\CCC\CSCS1320\Joe>
 +</cli>