10th Class Computer Chapter 01 – Introduction of Programming
What is Program / Computer Program / Software?
Ans: A program is set of instructions, given to computer to solve a specific task.
What is Programmer / Software Developer?
Ans: A person, who knows how to write a computer program correctively is called Programmer.
What is Programming Language?
Ans: Special Language, designed by computer scientists to interact with computers is called Programming Language. All programmers use these special languages to write programs. E.g. Java, C, C++ and HTML etc.
What is Compiler?
Ans: A Compiler is a software that converts program into low level language or machine language.
Computer only understand and work in machine or low level language consist of 0’s and 1’s, and human understand high level languages like English, Urdu, French etc. so compiler translated these
High level languages into Low Level.
What is Syntax and Syntax Error?
Ans: Every Language has its rules and regulations that is called grammar and Dictionary. This is
Also called Syntax. When we don’t follow the syntax of a language, this is Called Syntax Error.
E.g. if we write “Ptintf” instead of “printf” this is Syntax Error. Compiler does not understand and
Translate such words.
What is Reserve Word?
Ans: Each language has specific words that have specific meanings, these words are known as
Reserve Words. Compiler already know the functionality or meaning of these words. Programmer cannot define these words in his own.
Explain structure of a C Program?
Ans: Every C Language program is divided into three main parts:
- Link Section or Header Section
- Main Function
- Body of main ( ) function.
Link Section or Header Section: General structure for link or section is : #include <headerfilename>
Using this section, we include already defined functions in the language. These files, which have
Defined functions are called header files. E.g. we use “printf” and “scanf” functions which are
Already defined in “stdio.h” header file.
Main Function: It consist of a main() function. Every C language program must contain a
main() function and it is starting point of execution.
Body of main ( ) function: The body of main function is enclosed in curly braces { }.
{ body of main function }. All the statements inside these curly braces make the body of program.
What is comment? Also write the purpose and syntax of comments.
Ans: Comments are the statements in a program that are ignored by compiler and do not execute. Usually comments are written in Natural Languages i.e. English, Urdu etc.
Purpose of writing comments: Comments are the thoughts of program and programmer.
They facilitate other programmer to understand code.
They also help us to understand our own program after years of writing it.
Syntax of writing comments:
In C-language there are two types of writing comments:
- Single-Line Comment
- Multi-Line Comment
1. Single-Line Comment: single line comment starts with ‘//’. For example //this is comment
2. Multi-Line Comment: Multi-Line Comment start with ‘/*’ and ends with ‘*/’. For example
/* this is
Multi-line
Comment. */
What are Constants and Variables?
Ans: Constants: Constants are the values that cannot be change by the program, e.g. 5, 7, 100 etc.
There are three types of constants in C-language:
- Integer Constants
- Real Constants
- Character Constants
1. Integral Constants: Value without decimal point e.g. 123, 653, are known as integral constants, they can be positive or negative.
2. Real Constants: Values with decimal point e.g. 324.66, 987.321, -546.0098 are known as real constants. They can also be positive or negative.
3. Character Constants: any single small case, upper case letter, digit or punctuation is considered as character constant.
Variables: it is actually the name of a memory location, where data is being stored inside computer’s memory. The value of variable can be changed in a program. Each variable has unique name and data type. E.g.
int test float result char name.
Int, float and char are data types, where ‘test’, ‘result’ and ‘name’ are the name of variables.
In the following, we discuss different data types provided in C-language:
- Integral Variables:
- Float Variables:
- Character Variables:
What is integral Variables?
Ans: integer data type id used to store integral values. It takes 4 byte of memory to store an integral value. We use the keyword ‘int’ to declare integral variables.
What is Floating Point Variables?
Ans: Float data type is used to store floating values up to six digit precision. It takes 4 byte of memory to store a floating value. We use the keyword ‘float’ to declare floating point variables.
What is Character Variable?Ans: this variable can store only one character. It takes only one byte of memory to store character variable. We Use the keyword ‘char’ to declare character variable.
3 comments