Vous êtes sur la page 1sur 9

Prepared by BIT22 and BCS09

C language

Questions and answers

Chapter1

Lecture1

Que: what is computer ?

Ans: computer is electronic device that you can store data

Que: what are two types of computer?

Ans: hardware and software

Que: What is hardware and what is software?

Ans: hardware various devices comprising a computer such as keyboard , screen ,


mouse , disks , memory , CD-ROM , and processing units

Software: programs that run on a computer

Que: what are six logical units in every computer?

Ans: six logical units in every computer

1- Input unit (keyboard , mouse)


2- Output (screen, printer )
3- Memory unit
4- Arithmetic logic unit (ALU)
5- Central processing unit (CPU)
6- secondary storage unit

que: what are three types of programming language?

ans: three types of programming language are 1-machine language 2-assembly


language 3-high level language

Que: who evolved c language and where is from and when?


Prepared by BIT22 and BCS09
Ans: c evolved by Richie and from two previous programming language BCPL ,
AND B , in 1970 to traditional c

Que: when first standard c language created and updated?

Ans: standard c language created 1989 and was updated 1999

Que: what are six basics of typical c program development ?

Ans: 1- Edit 2-preprocess , 3-compile , 4-link 5-load 6-execute

Que: what means c portable language?

Ans: c language is portable language means programs can many different computer

Lecture2

Que: what are library files? And which extension they have?

Ans: library files are group of precompiled routines for performing specific tasks
and they have extension of .lib

Que: what is used printf function?

Ans: printf function is used to display text on the screen You can use printf() to
print numbers, strings or characters

Que: what are math libraries?

Ans: you are going to use floating-point arithmetic in your programs; you will
need another library file

Que: what are run time object files? And which extension they have?

Ans: files contain the code to perform various functions after your program is
running and they have extension of .OBJ

Que: what are header files or include files? And which extension they have?

Ans: are text files can be combined with your program before it is compiled and
they have extension of .h

Que: define source code?


Prepared by BIT22 and BCS09
Ans: Source code is a series of statements or commands that are used to instruct
the computer to perform your desired tasks

Ans: what is the steps program development cycle?

Ans: Use an editor to create a disk file containing your source code
with extension of c.

Compile the source code to create an object file.

Link the compiled code to create an executable file.

Run the program to see whether it works as originally planned

Que: what is function in c language?

Ans: The function is the one to which the control is passed when the program is
executed

Que: what are delimiters?

Ans: The Opening brace {indicates that a block of code that forms a distinct unit
is about to begin. The closing brace} terminates the block of code

Que: what is statement terminator?

Ans: The line in our program begins with the word printf() is an example of a
statement

Que: what means c is case sensitive?

Ans: c is case sensitive means C distinguishes between uppercase(capital letters)


and lowercase (small letters)

Que: what are surrounded strings and characters in c language?

Ans: In C Strings are surrounded with Double quotes while characters are
surrounded with single quotes

Que: what are format specifiers?


Prepared by BIT22 and BCS09
Ans: The format specifiers tells printf( ) where to put a value in a string and what
format to use in printing the value

Chapter2 lecture 1

Computer programs usually work with different types of data, these values
can be numbers or characters.
C has two ways of storing values, variables and constants.
A variable is a data storage location that has a value that can change during
program execution.
Variables may be the most fundamental aspect of any computer language.
A constant has a fixed value that can't change.
The variable name of c can contain letters, digits, and the underscore,
the first character of the name must be a letter.
C keywords can't be used as variable names.
A keyword is a word that is part of the C language.
Prepared by BIT22 and BCS09
A variable declaration tells the compiler the name and type of a variable
and optionally initializes the variable to a specific value.

The difference between Variable definition and a variable declaration:

Variable definition specifies the name and the type of a variable, and also
sets aside memory space for the variable.
A variable declaration, by contrast, specifies variables name and data type
but doesnt set aside any memory for the variable.
Variable declarations are important in multifile program, where a variable
definition that is defined in one file must be referred to in second file.

There are five foundational data types in C: character, integer, floating-


point, double floating-point, and valueless.
Most variable types in C are numeric except the character variable.
Character variable contains one character surrounded by single quotes.
There are two types of floating point the mantissa and the exponent.
The mantissa is the value of the number.
The exponent is the power to which it is raised.
Printf is a standard library function for displaying data on the screen.
The printf () function gives the programmer considerable power to format
the output.
The escape sequences allow you to use a sequence of characters to
represent special characters.

Chapter2 lecture2
Prepared by BIT22 and BCS09
The scanf is input function allows you to accept input from standard in,
which for us is generally the keyboard.
Scanf introduces two new symbols; the arithmetic operator (*) and the
address operator (&).
The scanf () function can accept input to several variables at once.
An address operator is a mechanism within C that returns the memory
address of a variable.
getche () is input function reads a single character from the keyboard and
echoes to the screen.
The get means it gets something from the outside world.
The ch means it gets a character.
The e means it echoes the character to the screen when you type it.
A statement is a complete direction instructing of the computer to carry out
some task.
In C, statements are usually written one per line, although some statements
span multiple lines.
White space refers to spaces, tabs, and blank lines in your source code.
If you place a semicolon by itself on a line, you create a null statement.
A compound statement, also called a block, is a group of two or more C
statements enclosed in braces.
An expression is anything that evaluates to a numeric value.
The simplest C expression consists of a single item: a simple variable, literal
constant or symbolic constant.
Complex expressions consist of simpler expressions connected by
operators. E.g.: 5+4.
Prepared by BIT22 and BCS09
An operator is a symbol that instructs C to perform some operation, or
action, on one or more operands.
An operand is something that an operator acts on.
C language has four operators:
1. The assignment operator: is the equal sign (=).
Its use in programming is somewhat different from its use in regular
math.
In a C assignment statement, the right side can be any expression,
and the left side must be a variable name.
2. Mathematical Operators (arithmetic): takes two operands.
binary mathematical operators

a. Addition (+) d.Divition (/)

b. Subtraction (-) e.Modulus/remainder (%)

c.Muliplication (*)

The unary mathematical operators: it takes a single operand.


o C has two unary mathematical operators:

Increment (++) and Decrement (_ _)

o The increment and decrement operators can be used only with


variables, not with constants.

3. Relational Operators: are used to compare expressions, asking questions

C has six relational operators: equal (==), Less than (<), greater than
(>),
Prepared by BIT22 and BCS09
Greater than or equal (>=), less than or equal (<=), and not equal
(! =).

When working with relational operators, true is equal to 1, and false


is equal to 0.

4. Logical Operators: let you combine two or more relational expressions


into a single expression that evaluates to either true or false.

Single expression that evaluates to either true or false.


It has the following operator: and (&&), or (ll), not (!)

Comments are added to C programs to make them easier to


understand.
These comments are ignored by the compiler and are just for the
programmers.

Chapter4

The main idea of a loop is to repeat an action or a series of actions.


C has three loop statement : the for ,the while and the do.while.
The while and for loops are pretest loops , and the do.while is a post-test
loop.
A for loop is used when your loop is to be executed a known number of
times.
Prepared by BIT22 and BCS09
In a for loop, dont place a semicolon between the loop expression and the
body of the loop.
The initialization expression in the for loop contains two statements,
separated by comma.
the while loop is actually uses the same elements, but they are distributed
throughout the program.

Vous aimerez peut-être aussi