Greetings everyone, Today I will show you how to develop a program. Developing a program is very easy if you follow this method. First you need to know, which type of program you want to develop. If you have any doubts and problem with developing a program then first create algorithm.
An algorithm is a plan of developing a program. The first step in the program development is to device and describe a precise plan of what you want the computer to do. This plan expressed as sequence of operation, is called in algorithm. Algorithm is just idea behind a program. An algorithm is a finite set of step by step defining the solution of a particular problem. The main advantage of algorithm is proper understanding of problem.
The second step after algorithm development is the flowchart development.
Flowchart is the graphical representation of algorithm. It makes use of symbols which are connected among them to indicate the flow of information and processing. It will show the general outline of how to solve a problem or perform a task. It is prepared for better understanding of the algorithm.
(if you don't know what is flowchart and algorithm then Follow the link .)
Algorithm and flowchart is only used for understand the actual logic of a program
Here, some simple examples so we can understand
Example
*Write a program to sum of two number
Algorithm
Step 1 - Start algorithm
Step 2 - Read two numbers a and b
Step 3 - Calculate the sum of a and b and store it in sum
Step 4 - Display the value of sum
Step 5 - Stop
Flowchart
After completing the two steps, the program become very easy to develop.
Now, create your program
When you create a program first you have to include a header files.
It is a library files ans system file.
Example: include<stdio.h>
After include header file you have to enter main() function.
the program always execute from main() function which may access another function. any other function definition must be define separately before or after main() function.
When you enter main() function, it instruct the compiler that program begin from here. Compilation and execution of the program starts from main() function.
After enter the main() function open the curly brace ({) and in a new line enter the variables that you have to use in your program.
If you have to enter integer numbers then use 'int' datatype.
If you have to enter character then use 'char' datatype.
If you have to enter floating point then use 'float' datatype.
If you have to enter double floating point then use 'double' datatype.
here in our program we use int.
Example; int a,b,c;
(note -The semicolon is use for end of the statement. and comments may appear anywhere within the program using '//')
Here, a and b store the values of two numbers and c store the sum of the two numbers.
Example:
printf("\n enter two number");
scanf("%d%d",&a,&b);
Here, printf only use to display the statement
and scanf is use for inserting values of the variables.
I'm using here int datatype so in scanf i'm gonna use %d%d for read an integer values.
'&'(ampersand) is used because here i'm inserting the values.
After enter two values insert the formula of sum.
c=a+b;
Then print the value of C
Example:
printf("\n Sum is %d",c); // \n is used to enter a new line
getch(); // getch() is used for display the output result.
When your program is completed then close curly brace(})
Full example of the program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr(); // clrscr is used for clear the previous result of output screen.
printf("\n Enter two numbers");
scanf("%d%d",&a,&b);
c=a+b;
printf("\n Sum=%d",c);
getch();
}
So, that was simple program to understand the development of the program. You can also practice using the formula of subtraction, division, multiplication. Developing an efficient program requires lot of practice and skill.
If you have any doubts and problem then ask me in comments, I will help you any time.
An algorithm is a plan of developing a program. The first step in the program development is to device and describe a precise plan of what you want the computer to do. This plan expressed as sequence of operation, is called in algorithm. Algorithm is just idea behind a program. An algorithm is a finite set of step by step defining the solution of a particular problem. The main advantage of algorithm is proper understanding of problem.
The second step after algorithm development is the flowchart development.
Flowchart is the graphical representation of algorithm. It makes use of symbols which are connected among them to indicate the flow of information and processing. It will show the general outline of how to solve a problem or perform a task. It is prepared for better understanding of the algorithm.
(if you don't know what is flowchart and algorithm then Follow the link .)
Algorithm and flowchart is only used for understand the actual logic of a program
Here, some simple examples so we can understand
Example
*Write a program to sum of two number
Algorithm
Step 1 - Start algorithm
Step 2 - Read two numbers a and b
Step 3 - Calculate the sum of a and b and store it in sum
Step 4 - Display the value of sum
Step 5 - Stop
Flowchart
Now, create your program
When you create a program first you have to include a header files.
It is a library files ans system file.
Example: include<stdio.h>
After include header file you have to enter main() function.
the program always execute from main() function which may access another function. any other function definition must be define separately before or after main() function.
When you enter main() function, it instruct the compiler that program begin from here. Compilation and execution of the program starts from main() function.
After enter the main() function open the curly brace ({) and in a new line enter the variables that you have to use in your program.
If you have to enter integer numbers then use 'int' datatype.
If you have to enter character then use 'char' datatype.
If you have to enter floating point then use 'float' datatype.
If you have to enter double floating point then use 'double' datatype.
here in our program we use int.
Example; int a,b,c;
(note -The semicolon is use for end of the statement. and comments may appear anywhere within the program using '//')
Example:
printf("\n enter two number");
scanf("%d%d",&a,&b);
Here, printf only use to display the statement
and scanf is use for inserting values of the variables.
I'm using here int datatype so in scanf i'm gonna use %d%d for read an integer values.
'&'(ampersand) is used because here i'm inserting the values.
After enter two values insert the formula of sum.
c=a+b;
Then print the value of C
Example:
printf("\n Sum is %d",c); // \n is used to enter a new line
getch(); // getch() is used for display the output result.
When your program is completed then close curly brace(})
Full example of the program
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr(); // clrscr is used for clear the previous result of output screen.
printf("\n Enter two numbers");
scanf("%d%d",&a,&b);
c=a+b;
printf("\n Sum=%d",c);
getch();
}
So, that was simple program to understand the development of the program. You can also practice using the formula of subtraction, division, multiplication. Developing an efficient program requires lot of practice and skill.
If you have any doubts and problem then ask me in comments, I will help you any time.

No comments:
Post a Comment