Share
Explore BrainMass

C Program With Sequence Structure Only

As you know, three fundamental control structure are sequence, selection and repetition. Can you write a C program using the sequence structure only? Can you avoid using selection structure? Repetition structure? What would you sacrifice in each case?

Solution Preview

A sequence structure is a set of program statements that are executed sequentially. A simple program can be written using the sequence structure only, without any sacrifices. For example, the sequence structure is implemented here in the instance function named "doSomething":

.............................................
void doSomething(){
cout << "Hello Viet Namn";
cout << "Hello Iraqn";
cout << "Hello American";
cout << "Hello Worldn";

}//end doSomething function
.............................................

The computer program allows us to have as many actions as we want in a sequence structure because it is built therein. Unless directed otherwise, the computer executes statements one after the other in the order by which they are written--that is, IN SEQUENCE.

* Can you avoid using selection structure?

You may avoid using the selection structure in certain situations, but not all because it is needed to execute one of two or more possible avenues of code. You will sacrifice the type of program you want to create because Selections Statements are needed to choose among alternative course of action. They are powerful tools that allow ...

Solution Summary

In computer science or programming, three fundamental control structures are sequence, selection and repetition. This is a sample C program using the sequence structure only.

$2.19