Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

C Prog Language

C programming language datatypes include built-in types like integers, floats, characters, and pointers. It also supports user-defined types like arrays, structures, unions, and enumerations. The language uses various operators, control flow statements, functions and pointers. Programs use input/output functions to read from and write to files, standard input/output. C has had a significant influence on many modern languages through its development history.

Uploaded by

Aman kumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

C Prog Language

C programming language datatypes include built-in types like integers, floats, characters, and pointers. It also supports user-defined types like arrays, structures, unions, and enumerations. The language uses various operators, control flow statements, functions and pointers. Programs use input/output functions to read from and write to files, standard input/output. C has had a significant influence on many modern languages through its development history.

Uploaded by

Aman kumar
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 8

C Prog Language (link)

Datatypes (link)
A container or memory place to hold data-tems.
Built-In Type (link)
Part of the language construct.
Integer
#include #include int main(){ printf("Storage size for int : %d
", sizeof(int)); return 0;}
Signed
int
16 bits
Ex:-32,768 to32,767
short int
8 bits
Ex:-128 to127
long int
32bits
Ex:-2,147,483,648 to 2,147,483,647
Unsigned
long int
32bits
Ex:-2.147,483,648 to 2,147,483,647
short int
8bits
Ex:-128 to 127
int
16 bits
Ex:-32,768 to 32767
Float
#include #include int main(){ printf("Storage size for float : %d
", sizeof(float)); printf("Minimum float positive value: %E
", FLT_MIN ); printf("Maximum float positive value: %E
", FLT_MAX ); printf("Precision value: %d
", FLT_DIG ); return 0;}
long double
80bits
Ex: 3.4E-4932 to 1.1E+4932
float
32 bits
Character
Character may be an alphabet or a digit or a special symbol. Ex: 'a', '5',
'%'
Signed char
8bits
Ex:-128 to127
Unsigned char
8bits
Ex: 0 to255
Char
Double
double
64bits
Ex: 1.7E-308 to 1.7 E+308
Derived Type
Derived from the existing datatypes.
Array
Funtions
Pointer
Reference
User Defined Types
Datatypes defined by the user.
Structure
Union
Enumeration
C- Tokens (link)
Special Symbols (Delimeters)
;,!?#$
Constants & Variables (link)
Numeric Constants
int
%d
decimal
Ex: -129, 78 etc
octal
Ex: 037, 5011 etc
hexadecimal
Ex: 0X2, 0XA3 etc
real
float
%f
Ex: -2.73, 0.71 etc
exponential
12e-2
-1.2E-1
Character Constants
Single
%c
'5'
ASCII Values => pf("%d",'a'); printf("%c",97);
'S'
String
%s
"Hello"
"!..?..34#"
Backslash
''
''
null
''
tab
''
new line
''
inverted comma
Keywords (link)
Basic Building Blocks
int
if
case
while
struct
auto
break
case
do
for
else
continue
goto
return
switch
union
void
float
char
long
int
short
double
sizeof
typedef
register
static
const
extern
define
Identifiers
May be varible or a function name or array varibale.
Ex: amount, sum etc
Strings
Ex" :SDMCET", "123"
Operators (link)
Operators operate on operands.
Arithmetic (link)
+
-
/
%
*
Logical (link)
||
&&
!
Assignment
+=
-=
*=
/=
%=
Conditional
exp1 ? exp2 : exp3;
Special
sizeof
, [comma]
Increment / Decrement (link)
post
++
pre
--
Bitwise
&
/
<<
>>
~
Relational (link)
<
<=
>
>=
==
!=
Expressions (link)
Expression may be constant or a variable or a combination of these
connected by operators.
Arithmetic
precedence
high
*
/
%
low
+
-
example
a*b-c ->a*b-c
3*x*x-x ->3x^2-x
Conversions
automatic type
follows the hierarchy of size of the operands
casting a value
(type name)exp;
Mathematical Functions
#include<math.h> cc filename -lm
example
exp(x)
fabs(x)
sqrt(x)
Input/Output
Read and Write statements.
Formatted
Input
scanf("control string", &arg1,&arg2..);
Output
printf("control string", arg1,arg2..);
Unformatted
putchar
putchar(variable_name);
getchar
Control Statements (link)
Used to control the flow of execution.
if (link)
simple if (link)
if(test exp){ body;} statement -x;
if else
if(test exp){ true-block}; else {false-block}; statement-x
nested if else
if(test exp1) { if(test exp2){ statement1} else {statement2;} else
{statement 3}; statement-x;
else if ladder
if(condition1) statement1; else if(condition2) statement2; else
if.........else if(condition n) statement n; else default statement
swicth (link)
switch(exp){ case value1:block1; break; case value2:block2;
break; ..........default:block; break; } statement-x;
conditional
conditional exp? exp1:true exp2:false
goto
Loops (link)
Used to repeat the task (set of statements)
continue (skip)
for (link)
for(initialize ; test exp ; increment) { body; }
while (link)
while(test exp) { body; }
do.. while (link)
do { body ; } while(test exp);
break (jump) (link)
Arrays (link)
Set of similar data items. Ex: Set of integers.
Dimensions (link)
One
Declaration
type var_name[size];
Initialization
type name[size]={list of values};
Two
Declaration
type name[row_size] [col_size];
Initialization
type name[row_size] [col_size]={{row list},{col list}};
Multi (link)
Declaration
type name[s1][s2][s3]....[sn];
Initialization
type name[s1][s2][s3]...[s3]={{list s1},{list s2}, {list s3}, {list s4}.....{list
sn}};
Character Array (String) (link)
Declaring / Initialising
char name[size];
Reading
scanf("%s",name);
Writing
printf("%s",name);
Design on Paper
Ms. Divya Khanure
Strings (link)
Collection of characters.
Concatenation
strcat(str1,str2); output is str1str2
Comparison (link)
strcmp(str,str2); ASCII str1 - ASCII str2, +ve if str1<str2, -ve if str1 > str2
Copying
strcpy(str1,str2); outputs str1="str2";
Length
n=strlen(str);
Substr and many more string functions are available... (link)
Built in function in ctype.h
isalpha(x)
isdigit(x)
isalphanum(x)
ispunct(x)
islower(x)
Functions (link)
A set of instructions to do a particular task.
declaration (link)
type name (type var1.......)
calling (link)
main() { name(var1........); }
Call By Value - actual value of parameters
Call By Reference - pointers
types
with no arguments no return type
with no arguments one return type
with arguments no return type
with arguments multiple return type
definition
syntax
type name(type var1........) { local declaration; executable part;
return(var); }
Recursion (link)
Function calling itself
Pointers (link)
Pointer is a varibale holding an address of another variable.House Number
(addr) : Pointers Members in a house: Values House Name : Identifier
declaring
datatype *pt_name
initialize
p=&quantity
accessing (link)
int quantity *p,n quantity=179; p=&quantity; n=*p
Structures / Unions (link)
Structure is nothing but a record.It is a user defined datatype or collection of
dissimilar data-items.
define a structure (link)
struct name; { data type member1; datatype member2;..........};
initialization members
main(){ struct name{ datatype mem1; datatype mem2;.....}; struct name
mem1={constant.....}; struct name mem2={constant......}; }
struct name{ datatype mem1; datatype
mem2;.....};mem1={constants.......}; main(){ struct name
mem2={constants.....};...............}
mode
r - read only
w - write only
a - appending data
Files (link)
Collection of related records.
Open
FILE *fp; fp=fopen("filename","mode");
Close
fclose(file_pointer);
Input
putc(c, fp1);
c=getc(fp2);
Access
position
n=ftell(fp);
reset position
rewind(fp);
moving
fseek(fp,offset,position)
Output
fprintf(fp,"control string",list);
fscanf(fp,"control string",list);
History of C (link)
ALGOL
BCPL
B
Traditional C
ANSI C
ANSI/ ISO C
Dennis Retchie
Few Other Links
Companies using C Programming Language
https://docs.google.com/spreadsheet/ccc?
key=0AvPic5Th8MOmdFdHc05mRHQwQmFNazk0T0N1RDRmcUE&usp=sharing#gid
=0
#include #include int main(){ printf("Storage size for float : %d
", sizeof(float)); printf("Minimum float positive value: %E
", FLT_MIN ); printf("Maximum float positive value: %E
", FLT_MAX ); printf("Precision value: %d
", FLT_DIG ); return 0;}
NPTEL Videos
http://nptel.ac.in/courses/106104074/
http://ekalavya.it.iitb.ac.in/eVideos/CS101/content/preview.html
NPTEL Slides (link)
Virtal Lab (link)
Spoken Tutorials (link)

You might also like