CS Notes Chapter No 2


PROGRAMMING IN C

Q1.Different between program syntax and programming semantic.

Ans: Program Syntax Syntax are rules of any programming language. It is the method to write program statements.

For example: Syntax of writing programming statement in “C” is as

printf(“escape sequence/format specifier /string”, variable/expression/ constant);

Program Sementic It describe the meanings of a statement. i.e what the statement will do.

Example:

product=x*y; Here semantic is that first x will be multiplied with y then the value will be assigned to variable product.

 

IV: What is OOP?

 

Ans: OOP stands for Object Oriented Programming. Object is a component of a programming language that is designed once and can be used again and again. It is a modern and easy way to write a program.Examples of OOP languages are C++ and JAVA.

The programming technique in which objects and classes are used is called object oriented programing.

V: What are characteristics of HIGH LEVEL LANGUAGE?

Ans: High level languages are closer to human language. High level languages are easy to learn, easy to understand, easy to write and easy to detect and remove errors in high level languages. Built in function are used in high level languages. The programs written in high level languages are machine independent.

VI: Different between compiler and Interpreter?

Ans: Compiler It is translation software used to translate high level language source program into machine language object program. It translates the overall program at one time. Examples of languages using compiler are C, C++ etc. Interpreter It is also translation software used to translate high level language program into machine language but line by line. Example: Basic, Visual Basic

VII: What is Header File?

Ans: Collection of standard library functions to perform different tasks is called header file. It is an essential part of C programming. Many header files can be included in a single C program. The extension of header file is .h(dot H). #include preprocessor directive is used to include header files in program. E.g.

 

#include<stdio.h>

#include<conio.h>

 

VIII: Different between source program and object program?

Ans: Source Program The program written in high level language is called source program. Source program in C-Language is saved with an extension (.c) e.g. first.c Object Program The program when converted to machine language is called an object program.

The object program is saved with an extension (.obj) e.g. first.obj

IX: What are reserved words?

Ans: These are also called keywords. They have special meaning to compiler. e.g. int, float, if, else, switch are reserved words. These are defined inside a language translator. Reserved words cannot be used as variable names.

X: Write rules for variable names.

Ans: Every programming language provides certain rules to create and use the variable name. These rules are given below.

 

Rules for variable names:

  • Variable name is always started with an alphabets and underscore.
  • Blank spaces are not allowed
  • No reserved words can be used as variable name.
  • No special symbol are allowed other than underscore.
  • Capital and Small letters have different meaning for compiler.
  • Length of variable name depends upon compiler.
  • The number may be used but not at the start of variable name.

XI: WHAT IS PURPOSE OF const QUALIFIER?

Ans: const qualifier is used to define constant value. It is used with preprocessor directives. const is a reserved word.

Syntax: const data type identifier = value;

e.g.

const int abc=50;

or

#define abc 50

LONG QUESTIONS

Q3: What is programming language?Explain different types of low level languages.

Ans: Programming languages are software used to create computer programs. There are two main categories of programming language.

  • LOW LEVEL LANGUAGE
  • HIGH LEVEL LANGUAGE LOW LEVEL LANGUAGE

There are two types of Low Level Language.

  • Machine Language 
  • Assembly Language

MACHINE LANGUAGE: Machine language is also called binary language. It is composed of 0 and 1. It is native language of computer. Computer can directly understand the machine codes. The programs are difficult to write learn and debug in machine language.

ASSEMBLY LANGUAGE: In this language English words i.e. commands are used. These are called mnemonics. To translate assembly language program into Machine Language Assembler software is used.

 

Q4: What is HIGH LEVEL LANGUAGE? Explain any five types of HIGH LEVEL LANGUAGE.

Ans: Programming languages in which all the commands comprise of English words are known as High level languages. Programs written in high level languages are easy to understand, develop and debug. Few common examples of high level language are. i. C Language: C language was developed by Dennis M. Ritchie of Bell laborites in 1972. It is procedural programming language with low level features.

  • C Language: C language was developed by Dennis M. Ritchie of Bell laborites in 1972. It is procedural programming language with low level features.
  • C++ Language: It was developed by Bjarne stroustrup in 1980s. It is an (OOP) language and is an extension of C language, it includes all the elements of C language with other features like objects, classes, events and object-oriented concept.
  • Visual Programming Language: These languages are used for developing GUI applications. These are fifth generation object oriented programming (OOP) languages. E.g visual basic, visual C++.
  • C# Language: It is an object oriented language. It was developed by Microsoft Corporation in 2000. It is used to write web application, games utilities, operating system.
  • JAVA Language: JAVA is an object oriented programming language developed by Sun microsystem in early 1991.

Q5: Explain different parts/modules of C language.

Ans:

  • EDITOR: It is a program in which C language programs are written. The extension of C Program is “ .c ” e.g. first.c
  • COMPILER: It is program that converts C language source program into machine language object program. The extension of compiled program is “.obj” e.g. first.obj
  • LINKER: It is a program that takes one or more object code combines it into a single executable file. Its extension is .exe e.g. first.exe.
  • LOADER: It is a program that is used to load C language program into memory and executes it.
  • DEBUGGER: Debugging is a process of locating and finding errors in C Program. A debugger is a program that helps user to remove errors in C program.