0% found this document useful (0 votes)
31 views5 pages

C Notes

The document discusses various commands, concepts, and components related to C programming. It covers topics like command line commands (dir, cd), redirecting input/output, error handling, data types, variables, operators, control structures, and more. Examples are provided throughout to illustrate the different concepts.

Uploaded by

Sage Dark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

C Notes

The document discusses various commands, concepts, and components related to C programming. It covers topics like command line commands (dir, cd), redirecting input/output, error handling, data types, variables, operators, control structures, and more. Examples are provided throughout to illustrate the different concepts.

Uploaded by

Sage Dark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

#C

Commands--

1.dir--This command displays the wide format of matching file names in the same
directory.
2.cd Directory--into the directory
3.cd .. ---out of the directory

REDIRECTING OUTPUT-----
1.Redirecting the terminal output to a new file--using--'>'
dir new.txt>cfile.txt
cfile.txt
2.This redirection symbol overwrites the file when used again.
hostname >cfile.txt
cfile.txt
3.To prevent overwriting, we use '>>'
hostname >>cfile.txt
cfile.txt

REDIRECTING ERROR---
1. error file extension--'.err'
2. '2'-stands for standard error in command prompt.
3. redirecting standard error to an error file
dir hello.txt>cfile.txt 2>output.err
cfile.txt #this displays the usual information
output.err #this displays 'File Not Found'
4. '1'--stands for standard output in cmd
5. '2>&1'---appends the output and the error in the same cfile.
dir 1.txt>cfile.txt 2>&1
cfile.txt

DISCARD THE OUTPUT----


1.'del' keyword is used
del cfile.txt

REDIRECTING INPUT--------
sort--takes input from the terminal
sort
start--opens a new file
start notepad p4.txt
to take input from a file--
sort <p4.txt

COMPONENTS OF A C PROGRAM----
1. execution of a c program starts from main function.
2. It can be void main, int main,cat main..-----types of main function.
3. 3.#include<stdio.h>--is very important
4. no issue with indentation,not necessary, not like python
5. we use printf --to print
6. n--newline
7. semi-colon is must be in everyline
8. return--we have to return 0 when using int main
9. when we use void main -- no need to use return 0
10. if 0 is returned, the it means that the program is executed successfully.
11. gcc new.o---to create object file
12. then execute the object file as--- a.exe

PARADIGM ----
FUNCTIONAL----
1.Scheme-It is a branch of lisp programming language.It is a paranthesised list.
2.Haskell--pure functional language used on large scale industrial application.
they are
written in terms of mathematical functions.(Calculus)
3.Miranda-It is mostly implemented on unique systems. It is useful for rapid
prototyping(3-D model for architecture)
LOGICAL------
1.ASP(Active Server Page): It is mainly used on framework on webpage building.
2.Prolog(Programming in logics): It is used in building databases but it is very
difficult to
build input output bases.
3.Datalog(Declarative logical programming): It consists of facts which are the True
statements under the datalog deduced from the known facts.
OOP(Object-Oriented)----
ex--python,Java,C++
-----------------------------------------------------------------------------------
---------
-------------TIOBE index---------
(The Importance Of Being Earnest)
TIOBE index for March 2023:
1.python
2.C
3.Java
4.C++
5.C#

APPLICATIONS OF C/C++----
1.Linux Kernel-C
2.Adobe systems-Photoshop &Illustrator
3.Mozilla-C++
4.Bloomberg-billionare website used for tradinig--c &c++
5.Callas Software
6.Symbiam OS-mobile os back in 2003, Nokia once preferred this.
Kernel: a part of OS ,an intermediator between os and backend(hardware and the
processor).They are written in C.
stdio.h---standard input output header file.
%d--format specifiers, this is for integer
__STDC_VERSION----known as MACRO--used to know the compiler status and the
compiler version.They are predefined statements.
gcc -v : this gives the version of gcc in the command terminal

DIFFERENT TYPES OF ERRORS--


1. Compile time Error
2. Link time Error
3. Run time Error
4. Logical Error
----------------------------------
1.Compile time Error---
i.Object files are not created.
ii.The compilation cannot go froward anymore(Fatal Error).

2.Run time error----


i.No output is shown.
ii.Since there is no error in compilation, the object file creation is possible but
when
executed it shows no output.
iii.This error occurs due to some illegal operation performed in the program.
ex: 1. divide by 0
2. trying to open a file which is not created
3. lack of free memory space (out of range cases)

3.Logical Error------
i. when you do not get the expected output.

4.Linking error---
i. here the program is executed/compiled successfully but executables(a.exe) are
not
generated. simple.o (obj) files are already created but the error occurs when
linking these
files.
ex: 1. incorrect header file
2. wrong function prototyping
3. when main is changes to Main

INPUT/OUTPUT FUNCTIONS--------
FORMATTED OUTPUT FUNCTION--prinf()
Syntax: int printf(const char*format,..)
1. On success---returns number of characters successfully written on the output
2. On failure---a negative number is returned

FORMATTED INPUT FUNCTION--scanf()


Syntax: int scanf(const char*format,..)
This function returns the following value:
1.>0: The number of items converted and assigned successfully
2.0: No item was assigned
3.<0: Read error encountered or end-of-file(EOF) reached before any assignment was
made

EOF error-- there is nothing to read at the end of the file


Float-------
It can take upto 6 digits after the decimal .
For float datatypes----
%width.precession f
%4.2f---------width of 4 spaces min before the number , after the decimal point
print 2
decimal points. Our system default settings problem, hence we do not see the
4spaces
width.
/r : before this the string is not printed, only the string after this is printed.
Double
It can take upto 14 digits after the decimal .
int-4 bytes
float-4 bytes
double-8 bytes
char-1 byte

IDENTIFIERS--
1.It is used to identify a variable,keyword,function or any other user defined
item.
2. It starts with (A-Z),(a-z),_0/more elements,_(digits[0-9])
3. C programming does not allow few punctuation characters such as #,@,% within
identifiers.
ex:int d=68;//variables
int d_section=68; //identifiers

VARIABLES---
1.A variable has name,location,type,life,scope and qualifiers
scope-local,global
type-int char float double
qualifiers-signed and unsigned

KEYWORS---(32 in C)
1.they are the identifiers that have a special meaning in C,they cannot be used as
variables.
ex: int, main, float,double,sizeof,struct,enum,bool,gets,fgets,etc.

OPERATORS----
set bit-
clear bit-
toggle bit-

-------------------
TERNARY OPERATOR--
Syntax: (condition)? statement if condition is True: statement if condition is
False
------------------
L value R value-

L value-unknowns
R value -knowns
------------------
LANGUAGE SPECIFICATIONS--

def--A documentation that defines a programming laguage so that users and


implementers can agree an what programs in that language mean.

de facto: It is a legally recognised practice but not realistic .


ex: Algol 68

de Jure: It is legally unrecognised but realistic in application.


ex: Perl programming - It is used for system administration and networking.

----------------------------------------------------
CONTROL STRUCTURES-
SELECTION STRUCTURES--
Syntax:
1. if
if(e1)
<block>|<stmt>
2. if-else
if(e1)
<block>|<stmt>
else
<block>|<stmt>

3.if-elseif-else
if(e1)
<block>|<stmt>
else if(e2)
<block>|<stmt>
else
<block>|<stmt>

4.switch
switch(expression)
{
case integral constant:<stmt>break;
case integral constant:<stmt>break;
default<stmt>;
}
5.for
for(e1;e2;e3)//e1:initialisation,e2:condition,e3:modification
<block>|<stmt>
6.while
while(e2)
<block>|<stmt>
7.do-while
do{
<block>
}while(e2);

You might also like