Posts

Showing posts with the label algorithm

Program Prime Numbers C Language

Image
Hey everyone, I want to share my experience with C language. This my program will print prime numbers. You simply enter the number of primes that you want to display. And this is the source code. #include<stdio.h> int main(){ int a, n, i, sum, total=0; printf("input how prime should print : "); scanf("%d",&n); for(a=1;total<n;a++){ sum=0; for(i=1;i<=a;i++){ if(a%i==0){ sum++; } } if(sum==2){ printf("%d ",a); total++; } } } It is a program from me, hopefully useful.

Why Should You Learn C ?

Image
Why Should You Learn C ? Although C is simple but do not underestimate it because C language is the most powerful programming language ever made. In this all-round IT world, many programming languages have sprung up and then used even out of use. So there must be a reason why C still exists today and until now almost no language can match its power. 90% of beginner programmer assumes that C has been replaced by Java, C #, etc., then why should learn C. I do not know why they have such statue but one thing I can be sure that they will not be able to outperform 10% which  have differ opinion from the others. The reason is simple, how can a skyscraper can stand if the foundation is not strong. C is a programming language developed by AT & T's Bell laboratory in the United States in 1972. It was written by a man named Dennis Ritchie. Now let's analyze why C language should be the first programming language you learn: I'm sure that no one can learn Java ...

Algorithm and Flowchart Simple Calculator

Image
Algorithm :  Initialize val1, val2, oprs, result  Input val1  Input val2  Choose operation (oprs) from +, -, x or :  If you choose operation (+), then the result = val1 + val2  If you select operation (-), then result = val1 - val2  If you select operation (x), then result = val1 * val2  If you select operation (:), then result = val1 / val2  Print results And this is the flowchart :

Algorithms and Programming Languages : How to implement algorithm in some programming languages?

Image
Algorithms and Programming Languages : How to implement algorithm in some programming languages? Consider the following example algorithm used to decompress the contents of array X (i) as below: The above algorithm consists of instructions. Although the instructions are written in codes close to computer programming languages, but the computer can not understand and execute those instructions. Computers can only understand if the instruction is written in a language called programming language. Here is given example of some programming languages as implementation of the above algorithm: It appears that the instructions in the Algorithm are intentionally made close to the instructions used in the programming language. So if it has been written the algorithm to solve a problem, then we can easily convert algorithm into form of programming language.
Image
Algorithms and Programming Languages: What is Algorithm The algorithm, in essence, is the flow of thought in completing a work which is poured in written form that can be understood by others. What is emphasized here is the flow of thought. A person's flow of thinking can be different from that of other people's minds to accomplish the same job with the same outcome. In the learning algorithm, it is planned that the one who will carry out the first flow is the computer. Computers are designed to be able to execute commands given by humans. The command can be given in the form of a set of instructions called programs. The program is written in a language called programming language such as COBOL Language, Basic Language, Pascal Language, C Language, Java Language, and many other languages. Of the many programming languages, the instruction writing can be the same, almost the same, completely different, for the same purpose. From the description above, can be under...