0% found this document useful (0 votes)
11 views

C Programming Material

Uploaded by

Srish S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

C Programming Material

Uploaded by

Srish S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Primary data types

These are fundamental data types in Cnamely integer(int), floating(float), charater(char) and void.
Derived data types
Derived data types are like arays, functions, stuctures and pointers. These are dicussed in detal later.

Primary Data type

void
Character Integer Float

char signed unsigned float

int
Signed int double
char
short int
ghort int
Ungigned long double
char long int
-long int

Integer type
itegers are used to store whole numbers.

Size and range of Integer type on 16-bit machine

Type Size(bytes) Range

int or signed int 2 -32,768 to32767

unsigned int 2 0 to 65535

short int or signed short int 1 -128 to 127


4
-2,147,483,648 to 2,147 483,647
long int or signed long int

unsigned long int 4 0to 4,294,967,295

Floating type
Floating types are used to store real numbers.
Size and range of lInteger type on 16-bit machine

Type
Size(bytes) Range

Float 4
3.4E-38 to 3.4E+38

double 8
1.7E-308 to 1.7E+308

long double 10
3.4E-4932 to 1.1E+4932

Character type
Character types are used to store characters value.
Size and range of Integer type on 16-bit machine

Type Size(bytes) Range


char or signed char 1 -128 to 127

unsigned char 1 O to 255

void type void type means no value. This is usually used tospecify the type of
functions.
Character set of C
character: Itdenotes any alphabet, digit or special symbol used to represent information.
Use: These characters can be combined to form variables, C uses constants,
Variables, operators, keywords and expressions as building blocks to forma
basic C program.
Character set:- The character set is the fundamental raw material of any language and they are
used to represent information. Like natural languages, computer
language will also have well defined character set, which is useful to build the programs.

The characters in C are grouped into the following two categories:

1 Source character set


a. Alphabets
b Digits
C. Special Characters
d. White Spaces

2. Executioncharacter set
Escape Sequence

Source character set

ALPHABETS
Uppercase letters A-Z
Lowercase letters a-z

DIGITS 0, 1,2, 3, 4,5, 6, 7, 8, 9


SPECIAL CHARACTERS

tilde % percent sign vertical bar at


symbol plus sign less than
underscore minus sign greater than
caret number sign equal to
& ampersand dollar sign slash left
parenthesis asterisk back slash
colon left
right parenthesis apostrophe
quotation mark semicolon
bracket {left flower
right bracket exclamation mark Comma

brace Question mark dot operator


right flower brace

WHITESPACE CHARACTERS

vertical tab
horizontal tab Iv
b blank space new line
carriage return form feed \n
Double quote 12
Back slash Single quote
Question mark Null Alarm (bell)

Exccution Character Set

Certain ASCIl characters are unprintable, which means they are not displayed on the screen or
printer. Those characters perform other functions aside from displaying text. Examples are
backspacing, moving to a newline, or ringing a bell.
They are used in output statements. Escape sequence usually consists of a backslash and a letter
or a combination of digits. An escape sequence is considered as a single character but a valid
character constant.

These areemployed at the time of execution of the program. Execution characters set are always
represented by a backslash () followed by a character. Note that each one of character constants
represents one character, although they consist of two characters. These characters combinations
are called as escape sequen ce.

Backslash character constants

Character ASCII value Escape Sequence Result

Null 000 \0 Null

Alarm (bell) 007 la Beep Sound

Back space 008 \b Moves previous position

Horízontal tab 009 Moves next horizontal tab


BASTC STRUTURE OLA CPROGRAME
|Docmentacien secden ISample Prog Crested by Bource
Used fer Comnents
Lk sectlon #incudetdio h>
tinchudeCconio.b>

Defnitien sectlen void fun);

Ghbal decaratien sectiam


[Vartable ased h more than one fnclon] int a=10;
void main)
crsa0;
Decaration part
Bxecutable part printf "'avahe inside main ):%d"a;
fun0:

|Subpregram section voidfun)


[User-defned Function)
nctiont pint"navlue inside fun0: %'a;
Fucien 2

Tactio
PSG
COLLEGE OF TECHNOLOGY
DEPARTMENT OF COMPUTER APPLICATIONS
BE
ELECTRONICS AND COMMUNICATION ENGINEERING - (G1& G2) Semester I
CONTINUOUS ASSESSMENT TEST I Date:07.11.2023

23L104 - PROBLEM SOLVING AND CPROGRAMMING


Time : 1 Hour 30 Minutes Maximum Marks: 50

INSTRUCTIONS:
1. Answer ALLquestions. Each Question carries 25 marks.
2. In each question, Subdivision a) carries 5marks(one mark for eachcarries
question).
10 marks each.
Subdivision b(i) and b(in) carries 5 marks each and subdivision c)
Answer any ONE question from Subdivision c
3. Course Outcome Table :
Qn 1 Qn 2
CO1 CO2
(5x1=5 Marks)
CO1:
guestion number and write answer alphabet
la.For question numbers I to II,mention the
of your choice in answer sheet.
understood by the cormputer?
i. Which of the following is a low level language
MATLAB D)Assembly language
A) Interpreted language B) Middle language C)
iü. For the flowchart given below predict the output
Strt

while
|<20

A) 10 B) 2 C) 20 D) 0

three way transfer of control?


iii. In C language which operator provides C) Increment D) Logical
A) Bitwise B) Conditional

Fillin the Blanks:


solve
iv. A provides a logical solution that is finite and clear step-by-step procedure to
the given problem and visualizes it using
incorrect
area of rectangle. ldentify the step number that used
V. The flowchart below calculates
symbol

Reed Lengh/Step 1
Roed BroStop 2
Area Length x Brondh/Slop 3

Prirt
Siep 4
Area

(2 x5=10 Marks)
1b. Answer both the questions:
algorithm. Write an algorithrn to find power of a given
i. List the characteristics to be satisfied by an
number
print the factorial of a given nurmber.
ii. State the purpose of flowchart. Draw flowchart to (1x 10 =10 Marks)

Describe each step with respect to the problem


lc Discuss the steps in program development steps.
of finding the roots of a quadraticequation ax+bxtc-0.
(511=5 Marks)
C02:
write answer alphabet of
2a.For question numbers I to IM, mention the question number and
your choice in answer sheet
i) The following program prints
main)
{ int x-0;
while(x<=4)
{ if(ttx%20)
break;
printf('x-%dt",x); }
return 0;}
A) x-1 B) x-4 C) x-0 D) x-2

iü) int main)


{int max=5;
int c =0;
for(; c <max;c++);
{printf("%d ".c); }
printf("ENDn");retun 0; }
A) END B) 5 END C) END 0 D) 12 END
)Given the input
for i-0, the
A) I I B)0 I statement printf"dD) 0%d",0 i)x prints
Fill in the Blanks
iv) op is
False guaranteed to execute at least one time irresective of the
condition is True or
v)How many times does the string PSG gets
printed for the code given below
int main0
{ int k.
for (k =3; k<5; kt+)
printf"n PSG);
retun ;}
2 b.
Answer both the questions: (2x5= 10 Marks)
L Wnte separste programs using else if ladderand conditional cperator to check whether the given
input character is Alphabet or Not an Alphabet based on ASCIl values.
(ASCII value of uppercase A-Z is 65 to 90 and Lowercase a-z is 97-122)

n Wntea program to ind the sum of allèven numbers îom 1toN where the value of Nis taken
as input.

2c. (1x 10 = 10 Marks)


i Wite a program to get input for the Customer number, previvus meter reading and current meter
reading Calculate the number of units consumed and the total electricity bill according to the
given conditions:
For first 50 units is Rs. 0.50/unit
For next 100 units is Rs. 0.75unit
For next 100 units is Rs. 1.20unit
For unit above 250 is Rs. 1.50unit
An additional charge of 20% is added to the bill.
(OR)
ii Differentiate between while and do while loop. Write a prognm to count the number of digits for
the given positive integer using while loop.
Sample Input / Output:
Input Enter a number : 1109
Output : Number of digits = 4
OPERA TOR- TRECE DEACE TABLE
Operator
Description Associativity
Parentheses or function call
Brackets or array
Dot or Member subscript
Arrow operator selection operator
left to right
++
Postfix increment/decrement
++
+ -
Prefix increment/decrement
! N
Unary plus and minus
not operator and bitwise complement
(type) type cast right to eft
&
Indirection or dereference operator
Address of operator
sizeof Determine size in bytes
Multiplication, division and modulus left to right
+V Addition and subtraction left to right
<< >> Bitwise left shift and right shift left to rght
< <= relational less than/less than equal to
relational greater than/greater than or left to right
equal to
== != Relational equal to or not equal to left to right
&& Bitwise AND left to right
Bitwise exclusive OR left to right
Bitwise inclusive OR left to ight
&& Logical AND left to right
Logical OR left to right
?: Termary operator right to eft
+=
|Assignment operator right to left
*=
Addition/subtraction assignment
&=
Multiplication/division assignment
Modulus and bitwise assignment
Bitwise exclusive/inclusive OR assignment
<<= >>=

comma operator left to right


AScTT TABLE

90kenoas05: S ascil -d
8 NUL 16 DLE 48 0 64 a 8 P 96
32 12 p
1SOH 17 DC1 33!49 1 65 A 81 Q97 a 113 q
2STX 18 DC2 34 50 2 66 B 8282 R
M
R 98 b. 114 r
3ETX 19 DC3. 35 # 51
5133 67
67 C
C 83S99 c 115 s
4EOT 28
20 DC4
36 $ 52 4 68 D 84 T 100 d 116 t
SENQ 21 NAK 37 % 53 5 69E 85 U 101 e 117 u
6ACK 22 SYN 38&54670. F 86 V 102 f118 v
7BEL 23 ETB. 39 55 7 716 87 W 183 g 119 w
8 BS 24 CAN 40 56 8 72 H 88 X 184 h 120 x
9 HT 25 EM 41) 579 73 I 89 Y 105 i 121y
18 LF 26 SUB 42 58 : 74J90 Z 186 j 122 z
11 VT 27 ESC 59 75 K 91 [ 107 k 123 4
12FF 28 FS 44 60<76 L 92 198 1 124
13 CR 29 65 45 61 =77 M 93 ] 19 25}
14 S0 30 RS 46. 678. N 94 118 n 126
15 SI 31 US 47 / 639 790 95 11 o 127 DEL

You might also like