User Tools

Site Tools


user:psechris:portfolio:cprogproject3

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

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;
}

Execution

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>
user/psechris/portfolio/cprogproject3.txt · Last modified: 2013/03/05 00:43 by psechris