answersLogoWhite

0

Here is a simple program that will tell you how to make an algorithm:

int main();

{

int length;

int width;

int total;

printf("What is the width: ");

scanf("%d", &width);

printf("What is the length: ");

scanf("%d", &length);

total = width * 2 + 2 * length; /*Here is the algorithm for finding the perimeter of a square*/

printf("The perimeter is: %d", total);

return 0;

}

Output:

What is the width: 32

What is the length: 55

The perimeter is: 174

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

How do you write a C plus plus program that displays a pyramid of Xes on the screen using a for loop?

printf ("x")


How do you write a program in C plus plus plus plus How do you write a program in C to swap two variables without using the third oneo swap two variables without using the third one?

To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


Would you Write c plus plus program using array for Fibonacci number?

You can write a C++ fib pro using arrays but the problem is the prog becomes very complicated since u need to pass the next adding value in an array.....


A program c plus plus on automorphic numbers or not?

how to write a program that counts automorphic number from 1 to 999


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


What is the importance of functions in a c plus plus program?

Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


How do you write program to convert meter to kilometer in c plus plus?

Divide it by 1000.


Do I need to write a program to find a substring in a given string in c plus plus?

No.


How do you write an Algorithm for a C plus plus Program?

You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.


How do you design a computer using c plus plus?

C++ is used to write programs, not to design computers. If you want to design computers, use a CAD program specifically intended to aid in electronics design.