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
printf ("x")
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.....
how to write a program that counts automorphic number from 1 to 999
Don't write, it is already written, google for 'cpp'.
Divide it by 1000.
printf ("x")
To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
I don't think its possible. Every C++ program must at least have the main function.
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.....
how to write a program that counts automorphic number from 1 to 999
By learning how to program on C+.
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.
Don't write, it is already written, google for 'cpp'.
Divide it by 1000.
No.
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.
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.