Program is a collection of information or instruction that give to the computer system for solving our problems. It is also known software. Every computer or device always work to our instruction which the user give. Programmer develop a program using their tools. A programmer is a user or person who develop a computer program. Some main benefits of computer science program are as follow:
- Various programs are use for various field to solve a number of problems.
- Program is less time consuming process
- A program can show the result of various of styles.
- And a program can access a large amount of data easily.
computer programs |
computer science programs
In C language a number of methods are use to write a c/c++ programs. Some of methods are as follow:
- Sequence
- Selection
- Loop
- Functions
- String
- Structure
- Array
- File Handling
- Two dimension array
- Built in Function
Sequence
In sequence method, the data use or access in order in which specifies. The data travels in sequence one after next and the process continue as well as long. In sequence no statement skip and never more than one time execute.
Sample Program using C language.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum;
clrscr();
a=10;
b=40;
sum=a+b;
printf("sum=%d",a+b);
getch();
}
Selection
In selection statement, there is condition is evaluate. IF the condition is true the statement is execute otherwise the else statement is execute. Suppose that a program is write a program that show a student marks if the marks are 50 or greater than show the result is pass otherwise the result is Fail.
Some example of selection are if, if-else,nested-if and switch.
Sample Program using C language.
#include<stdio.h>
#include<conio.h>
void main()
{
int marks;
clrscr();
marks=60;
if(marks>=50)
printf("congratulation! You have Pass");
else
printf("Sorry! You have Fail");
getch();
}
Iteration
Iteration is also know loop. Now a days, most of the programmer use loop of programming. In loop program write with while loop, do-while and for loop. Loop is a combination of some lines that are repeatedly.
Suppose that a user want to write the counting 1 to 100,000,000 on screen. This task is easy to perform and a single loop write counting easily.
Sample Program using C language.
#include<stdio.h>
#include<conio.h>
void main()
{
int count;
clrscr();
count=1;
while(count<=100000000)
printf("%d/n",count);
count=count+1;
getch();
}
Function
It is a some block codes these codes execute when it call by its names. It can convert the program into small piece. The program become very large if function is not use. Real reason of pieces is manage the program according to their instructions.
There are 2 main types use in function user defined function and built in function. In user define function the function write by programmer and built in function the ready made functions are use.
Some main benefits of function are as follow:
- It is a time saving process.
- It converts programs into codes.
- Easily reuse when require
- Easy to change
- Maintain easily
In sample of program using of function enter two numbers and fins the minimum number:
Sample Program using C language.
#include<stdio.h>
#include<conio.h>
void min(intx,inty);
void main()
{
int a,b,min;
clrscr();
a=37;
b=64;
min(a,b)
getch();
}
void min(intx,inty)
{
if(x<y)
printf("minimum number is x");
else
printf("minimum number is y");
}
Arrays
Arrays is name of location and its types in memory with same name and type. Array is use to store a large amount of same data. Some benefits of array are is Find process can apply easily, data store easily and it store a large amount of data.
We write a program using arrays enter ten numbers and find which is maximum number.
Sample Program using C language.
#include<stdio.h>
#include<conio.h>
void min(intx,inty);
void main()
{
int ar[15],j,maxi;
clrscr();
for(j=1;j<=10;j=j+1)
{
printf("Enter value");
scanf("%d",j);
}
maxi=ar[1];
for(j=1;j<=10;j++)
if(maxi<ar[j])
maxi=ar[j];
printf("maximum number is %d",maxi);
getch();
}
Related Topics.
For more detail visit
No comments:
Post a Comment
Thanks for Visiting