About Me

My photo
Vijayapur, Karnataka, India
I am interested in Teaching.

Sunday 19 February 2017

P C D Notes Page 1 of Module 1

Introduction to Computers and Programming
What is a computer?
Computer is an electronic computing device. It receives raw data as in input, process and generates desired as an output. If necessary, the input and output can be stored within computer’s secondary memory for future use.
Functions of a computer: The major four function of a computer system are as follows.
1. Input (reads raw data as input from user’s of machine)
2. Process (processes the input by using set of programs)
3. Output (result will be generated and displayed/printed)
4. Store (stores input & output within secondary memory)
What is computer program?
The set of instructions/statements/commands given to a machine by the programmer to do specific task is called computer program.
Who is programmer?
The person, who writes computer programs using(learning) computer programming languages like ALGOL, B, BCPL, C, C++, Fortran, COBOL, HTML, C#,Python, and Perl,etc.
Types of Computer Languages:
1. Machine level language (low level)
Machines knows, only 0s and 1s (binary digits i.e. bits) . It is difficult for the programmer to give instructions in machine level language to solve problem. Hence, researchers developed assembly and high level languages.
2. Assembly level language
The researchers developed assembly level languages to make computer programming easier. In this type, programmers will use mnemonics or abbreviations like ADD, SUB, MUL, DIV, STO, PRT, R1, R2, MOV, etc to give instruction to a machine.
e.g. MASAM (Microsoft’s Assembler)
Assembler: The translator or system program that converts the program written in assembly language in to machine language.
3. High level language
The researchers developed high level language to make computer programming easier. In this type, programmer makes the use of English words and mathematical operators and expression to write computer programs to do specific task. This language is easier to learn and write computer programs. Examples. ALGOL, B, BCPL, C, ANSI C, ISO C, C99, C++, Java, Python,etc.
Compiler: The translator or system program that converts the program written in high level language in to machine language at once.

Interpreter: The translator or system program that converts the program written in high level language in to machine language line by line (statement by statement).


Write a c program to display the “Hello World!” message on screen.
/* a c program to display the “Hello World!” message */
# include<stdio.h>
void main()
{
clrscr();
printf(“Hello World!”);
getch();
}

Write a c program to find addition of 2 unknown whole numbers.
/* a c program to find addition of two numbers */
# include<stdio.h>
void main()
{
int n1,n2,ans;
clrscr();
printf(“Enter any two numbers ”);
scanf(“%d%d”,&n1,&n2);
ans=n1+n2;
printf(“\n Addition is %d ”,ans);
getch();
}

Assignments: Write C programs for the following by your own.
1. To find addition of three unknown whole numbers.
2. To find addition of three unknown real numbers.
3. To find area and circumference of a circle.
4. To convert temperature reading from Fahrenheit to Celsius.
5. To find simple interest.
6. To find area and perimeter of a rectangle.
7. To find area of triangle by reading breadth and height of it.
8. To find area of triangle by reading 3 sides of it.
9. To swap (interchange) the contents of two variables (computer’s memories) using temporary variable.
10. To swap (interchange) the contents of two variables (computer’s memories) without using temporary variable.
11. To find square and cube of a number.

12. To extract and display last digit of entered number.

No comments:

GCD of two numbers and its application...

The greatest common divisor (gcd) of two numbers is the largest positive integer that divides both numbers without leaving a remainder. The ...