Articles‎ > ‎Technical Articles‎ > ‎

## Introduction

A Program has a three major components:

• Input Design
• Output

To write a program measure the following facts:

What are the Inputs will be given?
What is the Output?

For example,let us write a program for adding two Integer Numbers.

#include<stdio.h>

//Empty Main Function
void main( )
{
......
......

## Input Design

For this program we need two integer numbers for addition. And we declare  two variables named a,b as integer data type.

void main( )
{
int a,b;
......
}

And we need another variable named as c, which is used for storing  the result of the added numbers.

void main()
{
int a,b,c;
......
}

And get the two numbers from the user interface. In C we use printf and scanf functions
that syntax:

printf("Enter two Numbers:");

The above  statement is used  for displaying user interface information.

scanf("%d%d",&a,&b);

scanf is used to get the information from user screen.

In the above statement the first %d get the integer value of the variable a and store the value of a in a's memory location itself (&a is denoting the a's Memory Area).

Then the, second %d get the integer value of the variable b and store the value of b in b's memory location itself ( &b is denoting the b's Memory Area).

void main()
{
int a,b,c;
printf("Enter two Numbers:");
scanf("%d%d",&a,&b);
......
}

Here business logic is "adding two numbers". Business logic is doesn't affect any platforms,any languages it is most probably same think for all languages.

In this program, the two numbers a and b are added and stored in the variable  c.
So, we write
c = a + b;

Now we get,

void main()
{
int a,b,c;
printf("Enter two Numbers:");
scanf("%d%d",&a,&b);
c = a + b;
......
}

## Output Design

In C we use printf statement to show the output of the given program.
printf("Result :%d",c);

The above code prints Result : and %d replaces the c's Integer Value.

And  finally we get the following program in a full-fledged form, void main()
{
int a,b,c;
printf("Enter two Numbers:");
scanf("%d%d",&a,&b);
c = a + b;
printf("Result :%d",c);
}

R.G Dromy
How to Program