CH 2. BEGINNING WITH C Flashcards

(100 cards)

1
Q

C language was developed by ____________.

A

DENNIS RITCHIE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

C was developed at ___________.

A

AT & T Bells laboratory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

state the features of c language?

A

The features of c language are as follows:

  1. Robust language: c is a strong/structured language.
  2. general purpose: can perform both system and application tasks/programs.
  3. case sensitive language: c only accepts short letters otherwise its considered as an error.
  4. portable: c can be programmed in several devices it will execute the same output.
  5. c is a middle and low level language: c is categorised as both user level language (high level language) and machine level language(low level language).
  6. fast and efficient: c can be programmed and can execute the programs in a quick and efficient way.
  7. Modularity: c can solve large problems by dividing the tasks into modules/functions/procedures.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

state whether the following statement is Right or wrong;

c can only perform application tasks

A

wrong.

c is general purpose i.e it can perform both application and system tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

state whether the following statement is Right or wrong:

other letters apart from the short letters in programming in c is considered as error.

A

Right

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

state whether the following statement is Right or wrong:

c can give several outputs in different devices.

A

wrong.

output of the same program doesnt differ in devices if it is programmed in C.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

state whether the following statement is Right or wrong:

c can be both user level and high level language.

A

wrong.
As user level is called as high level language. c can be both machine level language (low) and user level language (high)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is modularity in c?

A

modularity is a feature of c where it divides big tasks into short modules/functions/procedures in order to execute them efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

write a basic c program that includes printf

A
#include
#include
void main()
{
 printf("welcome to c language");
getch();
clrscr();
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the use of:

printf()

A

the printf function is used to print an output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the use of:

main()

A

the main function is denotes the line from which execution of a program starts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what are comment lines?

A
comment lines ( /* *\ ) are
non executable statements in a program i.e which are ignored by compiler which is used for understanding the programs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

______ in programs helps in debugging and testing programs.

A

comment lines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

__ is a special character used in printf.

A

/n new line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

/n denotes _____.

A

new line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

lines in {} has to end with _____.

A

semicolon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

uppercase letters are used for ____.

A

symbolic constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

each statement in c must end with ___.

A

semicolon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

___ indicates beginning of a function.

A

open brace bracket. {

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

___ indicates end of a function.

A

closed braced bracket. }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

program in c should have ____ extension.

A

.c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is C character set?

A

1.A character denotes any alphabet,digits,special symbols, white spaces etc.
2. A character set comprises of the foll:
Letters or alphabets:A,B,C….,X,Y,Z a,b,c,…,x,y,z
Digits: 0123456789
Special characters: #@!$%^&*()?,;:”’+×÷=/_
White spaces: blanks, horizontal tabs, newline, formfeed, carriage return.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What are c tokens?

A

1.Smallest individual unit in c is called as tokens
2. The types of tokens are as follows:
Keywords/identifiers/constants/strings/ special symbols/ operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are keywords in c?

A

Keywords are words whose meanings have already been defined and the meanings cannot be changed.
Keywords are also called as reserved words.
There are 32 keywords in c.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
There are ___ keywords in c
32
26
Keywords should be written in ___.
Lowercase letters
27
What are identifiers in c
Identifiers are names given to arrays, functions and strings. These names are userdefined. They are made of combination of letters&digits. Cant be more than 8 characters long. Use of underscore is permitted.
28
what are constants in c?
constants are fixed value which does not change during execution of program.
29
what are the types of constants in c?
there are two main types of constants in c namely, numeric constants and character constants. numeric constants include integer and real constants whereas character constants includes single character constants and strings.
30
what are integer constants?
integer constants include constants which doesnot include decimal. integer constants are sequence of digits and they must have atleast one digit. integer constant can be positive or negative.
31
if there are no signs preceding integer constants, they are assumed to be ____.
positive
32
state true or false: | Embedded spaces, commas, special characters are allowed in integer constants.
false
33
state and explain the types of integer constants
integer constants can be categorised into 3 types: decimal constants includes sequence of digits which can be positive or negative octal constants digits from 0 to 7with leading 0 hexadecimal constants Sequence of digits from 0to 15 starting from OX,Ox and represents A/a to F/f for 10 to 15.
34
give examples of following: | decimal integer constants
32561 74628933 022164
35
give examples of following: | octal integer constants
0x43 0X57 0x664
36
give examples of following: | hexadecimal integer constants
OX45AD | Ox34
37
explain real constants
real constants are used to represent values that vary continously like temperature, distance etc. it has a decimal point. can be positive or negative.
38
state and explain the ways of representing real constants.
there are two ways of representing real constants namely: decimal form and exponential form in decimal representation, the constant has a decimal point. can be positive or negative. eg. 12.563 exponential form, the constants are divided into 2 parts: mantissa and exponenet and the form is mantissa e exponent. both mantissa and exponent value can be positive and negative. eg: 2.4e9 (e9 multiply by 10^9)
39
exponential notation is also called ____
scientific notation
40
explain: single character constants
single character constants include a single character (single alphabet, single digit, single special symbol) inside single quotation marks. eg 's'
41
explain: string character constants
sequence of characters enclosed in double quotes. this characters includes letters digits special symbols as well as blank spaces. eg "3212#"
42
character constants have int values which are called as ___
ancii values
43
blank spaces are permitted in ___constants
string
44
does "W" has an int ancii value?
NO
45
what is a variable?
a variable is an dataname used to store data value. variable are names given to locations in memory where constants are stored. variables keeps changing values at diff time of execution.
46
____are names given to locations in memory where constants are stored.
variables
47
variable name
combination of alphabets, digits, underscore. first character should be an alphabet. variable name are case sensitive eg: a_12
48
____ should not be a keyword.
variables
49
TRUE/FALSE: variable name are case sensitive
true
50
TRUE/FALSE: comma, space are allowed in variables
false
51
TRUE/FALSE: backslash characters are used to take inputs in specific form
false. used to print/gives outputs in certain way
52
the character combination in backslash characters are called as ___
escape sequences
53
___ is considered as alphabets in c. (Variables, tokens,character set)
Character set.
54
____ are words in c. (Functions, instructions, tokens)
C Tokens
55
We use ___ to construct keywords and variables (characters, tokens, identifiers)
Tokens
56
The grammer in c is called ___. (Errors, syntax, logic)
Syntax
57
C is strongly associated with ___ (linux, unix, none)
Unix
58
C compiler has features of __. (High level language, 4th generation language, low level language)
Low level language
59
C porgram is collection of ___ supported by c library (tokens, functions, instructions)
Functions
60
One can only use functions from c library. (T/F)
False. One can also make/use their own functions which can also be added in c library
61
Set of statements in C is written under ___. ; {} ()
{}
62
___ is used to improve readability of program (//, ; , blank spaces)
// and blank spaces
63
Carriage return is part of ___ (special symbol, white spaces, none)
White spaces
64
One must not use __ as variable names (operators, functions, keywords)
Keywords
65
Goto is a ___. (Statement, keyword, identifier)
Keyword
66
____ includes functions,arrays and variables (keywords, character set, identifiers)
Identifiers
67
An ___ cant be more than 8 characters long. (String, operators, identifiers)
Identifiers
68
Identifiers can be upto 8 characters long (true,false)
False. They cant
69
One can use _ in ____. (Variables, identifiers, keywords)
Identifiers
70
Blank spaces are permitted in identifiers. (T/F)
False
71
Real and int constants are the types of constants. (T/F)
False. Numeric/character
72
___ is also called floating point constants. (Decimal, octal, real)
Real
73
Default sign of all constants is positive. (T/F)
True
74
___ stores datavalue. (Keywords, variables, functions)
Variables
75
___ are case sensitive. (Keywords, identifiers, variables)
Variables
76
State the types of datatypes supported by c
PRIMARY USERDEFINED DERIVED EMPTY
77
___ datatype includes arrays, functions and pointers. (Primary, userdefined, derived)
Derived
78
Range of values for int is ___
-32,768/32,767
79
___ occupies 2 bytes
Int
80
Int range varies from machine (t/f)
True.
81
Int values are -32,768 to 32,767 for 16 bit word length (t/f)
True
82
Float occupies 32 bits for 8 digit precision (TRUE/FALSE)
False. 6 digit precision
83
___ char falls in range of -128,127. Signed,unsigned)
Signed
84
Signed char has range 0-255 (T/f)
False. Unsigned
85
Signed, unsigned are ___. (Datatypes, keywords, qualifiers)
Qualifiers
86
``` Match the foll: A. Int Float Char B. 32 bits 8 bits 2 bytes ```
Int: 2 bytes Float: 32 bits ie 4 bytes Char: 8 bits ie 1 byte
87
"Variable=expression" are operands (T/F)
False. Operands are expression on RHS of arithmetic instructions. They include constants and variable names
88
Are the following statements valid? State reasons for your answer. p x q = a;
Illegal statement since X is used not ×.
89
``` Observe the following instruction: char a,b; int c; a= 'p'; b='m'; c= a+b; How will the foll be added? ```
Ancii values should be assigned to a,b.
90
/+÷ has high priority in c (true/false)
False. */% has high priority
91
___ has the least priority. (-,+,=)
=
92
Explain heirarcy of operators in c.
Explain in own words. Refer pg 32
93
``` Match the foll: A. p/q=32 3×2=3.2 2.0×0=0 B. Real arithmetic Int arithmetic Mixed mode arithmetic ```
a=int arithmetic b=mixed mode c= real arithmetic
94
Explain the foll with example: int arithmetic, mixed mode arithmetic
Ans in own words: pg 36, 38
95
``` Observe the following program: #include void main() { int n; float p,r,interest; clrscr(); printf("enter principal amt"); scanf("%f",&p); printf("/n enter rate of interest and no of years"); scanf("%f%f",&r&n); interest=p*n*r/100; printf("the si is %f interest"); } This program depicts: ____(arithmetic instruction, basic c program, computational instruction) ```
Arithmetic instructions
96
___ is used to compare values in program.
Relational operator
97
True/false: arithmetic operator can be used in either side of relational operator
False, Arithmetic expresssion.
98
arithmetic operators have high justification as compared to relational operator. Justify why.
Eg: p=12,q=23 | p+q
99
Explain the use of logical operators
Own words. Pg 40
100
Explain the dogference between post and pre increment/decrement.
Pg. 42