CH 2. BEGINNING WITH C Flashcards

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
Q

There are ___ keywords in c

A

32

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

Keywords should be written in ___.

A

Lowercase letters

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

What are identifiers in c

A

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.

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

what are constants in c?

A

constants are fixed value which does not change during execution of program.

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

what are the types of constants in c?

A

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.

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

what are integer constants?

A

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.

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

if there are no signs preceding integer constants, they are assumed to be ____.

A

positive

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

state true or false:

Embedded spaces, commas, special characters are allowed in integer constants.

A

false

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

state and explain the types of integer constants

A

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.

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

give examples of following:

decimal integer constants

A

32561
74628933
022164

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

give examples of following:

octal integer constants

A

0x43
0X57
0x664

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

give examples of following:

hexadecimal integer constants

A

OX45AD

Ox34

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

explain real constants

A

real constants are used to represent values that vary continously like temperature, distance etc.
it has a decimal point. can be positive or negative.

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

state and explain the ways of representing real constants.

A

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)

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

exponential notation is also called ____

A

scientific notation

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

explain: single character constants

A

single character constants include a single character (single alphabet, single digit, single special symbol) inside single quotation marks.
eg ‘s’

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

explain: string character constants

A

sequence of characters enclosed in double quotes. this characters includes letters digits special symbols as well as blank spaces. eg “3212#”

42
Q

character constants have int values which are called as ___

A

ancii values

43
Q

blank spaces are permitted in ___constants

A

string

44
Q

does “W” has an int ancii value?

A

NO

45
Q

what is a variable?

A

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
Q

____are names given to locations in memory where constants are stored.

A

variables

47
Q

variable name

A

combination of alphabets, digits, underscore. first character should be an alphabet. variable name are case sensitive eg: a_12

48
Q

____ should not be a keyword.

A

variables

49
Q

TRUE/FALSE: variable name are case sensitive

A

true

50
Q

TRUE/FALSE: comma, space are allowed in variables

A

false

51
Q

TRUE/FALSE: backslash characters are used to take inputs in specific form

A

false. used to print/gives outputs in certain way

52
Q

the character combination in backslash characters are called as ___

A

escape sequences

53
Q

___ is considered as alphabets in c. (Variables, tokens,character set)

A

Character set.

54
Q

____ are words in c. (Functions, instructions, tokens)

A

C Tokens

55
Q

We use ___ to construct keywords and variables (characters, tokens, identifiers)

A

Tokens

56
Q

The grammer in c is called ___. (Errors, syntax, logic)

A

Syntax

57
Q

C is strongly associated with ___ (linux, unix, none)

A

Unix

58
Q

C compiler has features of __. (High level language, 4th generation language, low level language)

A

Low level language

59
Q

C porgram is collection of ___ supported by c library (tokens, functions, instructions)

A

Functions

60
Q

One can only use functions from c library. (T/F)

A

False. One can also make/use their own functions which can also be added in c library

61
Q

Set of statements in C is written under ___. ; {} ()

A

{}

62
Q

___ is used to improve readability of program (//, ; , blank spaces)

A

// and blank spaces

63
Q

Carriage return is part of ___ (special symbol, white spaces, none)

A

White spaces

64
Q

One must not use __ as variable names (operators, functions, keywords)

A

Keywords

65
Q

Goto is a ___. (Statement, keyword, identifier)

A

Keyword

66
Q

____ includes functions,arrays and variables (keywords, character set, identifiers)

A

Identifiers

67
Q

An ___ cant be more than 8 characters long. (String, operators, identifiers)

A

Identifiers

68
Q

Identifiers can be upto 8 characters long (true,false)

A

False. They cant

69
Q

One can use _ in ____. (Variables, identifiers, keywords)

A

Identifiers

70
Q

Blank spaces are permitted in identifiers. (T/F)

A

False

71
Q

Real and int constants are the types of constants. (T/F)

A

False. Numeric/character

72
Q

___ is also called floating point constants. (Decimal, octal, real)

A

Real

73
Q

Default sign of all constants is positive. (T/F)

A

True

74
Q

___ stores datavalue. (Keywords, variables, functions)

A

Variables

75
Q

___ are case sensitive. (Keywords, identifiers, variables)

A

Variables

76
Q

State the types of datatypes supported by c

A

PRIMARY
USERDEFINED
DERIVED
EMPTY

77
Q

___ datatype includes arrays, functions and pointers. (Primary, userdefined, derived)

A

Derived

78
Q

Range of values for int is ___

A

-32,768/32,767

79
Q

___ occupies 2 bytes

A

Int

80
Q

Int range varies from machine (t/f)

A

True.

81
Q

Int values are -32,768 to 32,767 for 16 bit word length (t/f)

A

True

82
Q

Float occupies 32 bits for 8 digit precision (TRUE/FALSE)

A

False. 6 digit precision

83
Q

___ char falls in range of -128,127. Signed,unsigned)

A

Signed

84
Q

Signed char has range 0-255 (T/f)

A

False. Unsigned

85
Q

Signed, unsigned are ___. (Datatypes, keywords, qualifiers)

A

Qualifiers

86
Q
Match the foll:
A.
Int 
Float      
Char 
B. 
32 bits
8 bits 
2 bytes
A

Int: 2 bytes
Float: 32 bits ie 4 bytes
Char: 8 bits ie 1 byte

87
Q

“Variable=expression” are operands (T/F)

A

False. Operands are expression on RHS of arithmetic instructions. They include constants and variable names

88
Q

Are the following statements valid? State reasons for your answer.
p x q = a;

A

Illegal statement since X is used not ×.

89
Q
Observe the following instruction: 
char a,b;
int c;
a= 'p';
b='m';
c= a+b;
How will the foll be added?
A

Ancii values should be assigned to a,b.

90
Q

/+÷ has high priority in c (true/false)

A

False. */% has high priority

91
Q

___ has the least priority. (-,+,=)

A

=

92
Q

Explain heirarcy of operators in c.

A

Explain in own words. Refer pg 32

93
Q
Match the foll:
A. p/q=32 
     3×2=3.2
     2.0×0=0 
B. Real arithmetic 
    Int arithmetic 
    Mixed mode arithmetic
A

a=int arithmetic
b=mixed mode
c= real arithmetic

94
Q

Explain the foll with example: int arithmetic, mixed mode arithmetic

A

Ans in own words: pg 36, 38

95
Q
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)
A

Arithmetic instructions

96
Q

___ is used to compare values in program.

A

Relational operator

97
Q

True/false: arithmetic operator can be used in either side of relational operator

A

False, Arithmetic expresssion.

98
Q

arithmetic operators have high justification as compared to relational operator. Justify why.

A

Eg: p=12,q=23

p+q

99
Q

Explain the use of logical operators

A

Own words. Pg 40

100
Q

Explain the dogference between post and pre increment/decrement.

A

Pg. 42