You are on page 1of 29

AN INTERNSHIP –II (SAI-ACADEMIA)

REPORT ON-

APPLICATIONS OF COMPUTER SCIENCE in C PROGRAMMING,


MATLAB AND LaTeX

A report submitted in partial fulfilment of the requirements for the Award of Degree of

Bachelor of Technology (B-TECH)

1
ABSTRACT

C is a general-purpose programming language created by Dennis Ritchie at the


Bell Laboratories in 1972. It is a very popular language, despite being old. C is
strongly associated with UNIX, as it was developed to write the UNIX
operating system. It is one of the most popular programming languages in the
world. It is very fast, compared to other programming languages, like Java
and Python. C++ was developed as an extension of C, and both languages have
almost the same syntax. The main difference between C and C++ is that C++
support classes and objects, while C does not. A C program can vary from 3
lines to millions of lines and it should be written into one or more text files with
extension. It was initially used for system development work, particularly the
programs that make-up the operating system.

2
TABLE OF CONTENTS
CONTENTS PAGE NO
Institute Description 6

Methodology 7

Introduction 8

What is C? 10

 Features of C
 Fundamentals of C
 Data Types
 Library Functions
 Operators and Expressions
 Statements
 Looping
 Functions
 Recursion
 Array

Overview of Matlab 24

Overview of Latex 27

Conclusion 30

References 31

3
INSTITUTE DESCRIPTION

Cyberland Institute of Computer is an esteemed institute situated in Jorhat. The


institute facilitates not only with one or two, but many courses related to the
Information Technology, popular known as the IT sector. It enables students to
amplify skills and hence enhance our learning experiences in various aspects
throughout life. It is a modern and an innovative training institute which
provides high quality Computer Education to the students interested in pursuing
Informatics Practices from all sectors of the society.
Cyberland Institute of Computer run wide range of degree, and various
certification courses including coding, AutoCAD and many more.
The institute is well facilitated with the necessary equipment and is blessed with
quality faculty members. Hence this place becomes a great place to provide
ample opportunities and exposure to students; especially helping them to gain
experience and expertise through various internship programs.

4
METHODOLOGY

This study report discusses about the use of various software applications like
C-programming, MATLAB, Latex, etc. This study was conducted with the help
of university professors and teaching staff with the help of modern computers.
This programme provided us prolonged and tailored help to understand, learn
and implement the use of these softwares in real world. My colleagues and I
allocated ourselves in a well-recognised Computer Institute for a crash course
with a duration of one month.

Our group learned these Programming languages from the rock bottom to a
notably well state. We were not only taught to write a programme but also to
implement it sideways. As an engineering student, programming softwares are
the backbone for each. All these learning and studying of theories makes no
sense if we can’t implement them in our real world. Implementing requires
simulation, and this is where these softwares are top most necessary.

After completion of our course, we were provided with valuable Certificates.


This research not only helped us to learn a computer language but also taught us
the importance of these in an individual’s life in implementing his ideas.

5
INTRODUCTION TO COMPUTER APPLICATIONS
In the present context, computers are everywhere and we find their
applications in various fields especially in the places where computations are
required and need to be done at a very fast speed.

Applications of Computer refers to the scope and use of the computer


system in various fields and sectors

The various areas of computer applications are:-}

 EDUCATION.
 TRAINING.
 ENGINEERING.
 SCIENCE AND RESEARCH.
 ENTERTAINMENT.

We can use our computer system for different applications by switching


to various programs and software packages, some of them are:-

 The C programming language is the recommended language for


creating embedded system drivers and applications. The availability of
machine-level hardware APIs, as well as the presence of C compilers,
dynamic memory allocation, and deterministic resource consumption,
makes this language the most popular.

 MATLAB is a proprietary multi-paradigm programming language and


numeric computing environment developed by Math Works. MATLAB
allows matrix manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces, and interfacing
with programs written in other languages.

6
 LaTeX is a software system for document preparation. When writing, the
writer uses plain text as opposed to the formatted text found in
WYSIWYG word processors like Microsoft Word, LibreOffice Writer
and Apple Pages.

7
WHAT IS C?
The C programming language was developed at Bell laboratories by Dennis
Ritchie during the early 97. It was derived from a computer language named B
and from an earlier language BCPL (Basic Combined Programming Language).
Initially it is defined as a system programming language under UNIX.

C as a programming language is rather like Pascal or Fortrum. Values are stored


in variables and programs are structured by defining and calling functions. C as
loops, if statements and function calls to have a control over the programmed
flow. Input and output can be directed to the terminal or to files. Related data
can be stored together in arrays or structures.

FEATURES OF C:
 Portable.
 Less lines of code.
 Procedural Programming.
 Middle Level Language.
 Popular choices for system level apps.
 Wide variety of built in functions, standard libraries and header files.

C FUNDAMENTALS
CHARACTERISTICS: C used the uppercase letters A-Z and lowercase letters
a-z and the digits 0-9 and some special characters as building block to form a
basic programming language i.e constant, variables, generator and expression.

IDENTIFIERS: They are the names given to various program elements such as
variable, function and array. Identifier consists of letters; digit in any order
except first character must be letter. Uppercase and lowercase letters both are
permitable. But they are not interchangeable. But we favour lowercase letter.
Undercase character can also be included and consider as a letter.

8
KEYWORD: There are certain reserved words for keywords that have standard
pre-defined meaning in C. This keyword can be used only for their intended
purpose. They cannot be used as programmer defined identifier. For eg: break,
case, char, continue, auto, default, do, double, else, float, for, go to, if, int, long,
return, short, struct, void, switch, while, etc.

DATA TYPE: C supports several different types of data each of which may be
represented differently within the computer memory. The basic data types are
listed below:

DATA TYPE MEANING MEMORY


REQUIREMENT
INT Integer 2 byte

CHAR Single Character 1 byte

FLOAT Floating Point 4 byte

DOUBLE Floating Point 8 byte

LIBRARY FUNCTIONS:
The C language is accompanied by a number of library functions that carry
various operations and calculations. In C to use this library function it may be
necessary to include certain specific information within the main portion of the
program. This information is generally stored in special files which are supplied
with the compiler. Thus, the required information can be obtained simply by
accessing these files. This is accomplished with the pre-processor directive
statements #include i.e

#include <filename>

9
where filename represents the special files. The name of this special files are
specified by each individual implementation of C. The certainly used common
file names are:

stdio.h, stdlib.h, math.h

The suffix h generally designates as header files.

DATA INPUT- OUTPUT STATEMENT:

Input data can enter into the computer from a standard input device by means of
C library function “scanf”. The general form of the “scanf” function is

scanf(“control string”, arg1, arg2,……….,argn);

where, “control string” refer to string containing required formatting


information and arg1, arg2,……, argn are argument that represents the
individual input data item.

The control string consists of individual group of character with one character
group for each input data item. Each character boot must begin with a “%”
followed by a conversion character. The most frequently used conversion
characters are:

CHARACTER MEANING

C Single character

D Decimal integer

F Floating point value

S string

10
The argument are written as variable or array whose type match the
corresponding character group in the control string. Each variable name must be
predicted by ‘&’ percent.

Output data can be written from the computer on a standard output device using
the library function printf. The general form of this function is:

printf(“control string”, arg1, arg2,……..,argn);

where, “control string” refer to the string that contain formatting information
and arg1, arg2, argn are argument that represents the individual output data
item. The control string consists of individual group of characters with one
character group for such output data item. Each character group must begin with
a ‘%’ sign followed by conversion characters. Incontrast to the scanf functions
arguments in the printf function doesnot represent memory address. Therefore,
arguments are not provided by ‘&’.

printf(“%d%f%c”, a,b,c);

OPERATOR AND EXPRESSION

C include a large no of operator which falls into several different categories, the
data that the operator acts upon are called operant. Some operator requires two
operands while other act upon only one operant. And some operator in C acts
upon 3 operands.

BINARY OPERATOR:-

Arithmetic operator: - There are 5 Arithmetic operators in C.

11
OPERATOR MEANING
“+” ADDITION
“-” SUBSTRACTION
“*” MULTIPLICATION
“/” DIVISION
“%” MODULUS

RELATION OPERATOR:-

There are four relation operators in C:-

 <
 <=
 >
 >=

Here closely related with the relation operator there are 2 equality operator.

 = = (EQUAL TO)
 ! = (NOT EQUAL TO)

In addition to the relational equality operators, C contain 2 logical operator

 && (AND)
 || (OR)

12
ASSIGNMENT OPERATOR:-There are several different assignment operator
in C but the most commonly used assignment operator is “=”. In addition to this
equal operator. C contains another 5 Assignment operator.

 +=
 - =
 *=
 / =
 %=

Conditional operator (primary operator):-Conditional operation can be


carried out using a conditional operation (? :) and expression that make use of
the conditional operator is called Conditional expression.

Such an expression can be written in case of tradition if/else statement. This


conditional expression is written as (exp1?, Exp2:, exp3.)

{C = a > b? a + b: b – a.}

SYMBOLIC CONSTANT:-

A symbolic constant is a name that substitutes for sequence of Characters of


characters. The characters may represent numeric, character or string constants.
Symbolic constants are generally used at the beginning of a program. The
symbolic constant may appear later in the program in place of numeric,
character or string constants.

Symbolic constants may defined by writing #define name value. Names are
generally written in uppercase letter. If the program requires pi value then we
can define by

13
(# define Pi 3.14159).

CONTROL STATEMENT:-

In most of the C programme instruction are exhibited in the same order in which
they appear within the program. The program of this type is unrealistically
simple. Since they don’t include any logically control structure.

A realistic C program may require that a logical phase be carried out at some
particular point within the program. One of several possible actions will then be
carried out depending on the outcomes of the logical case. This is known as
BRANCHING. In addition the program may require that a group of instructions
be executed rapidly until some logical conditions has been satisfied this called
as looping.

All of this operation can be carried out using the various operation statements in
C.

BRANCHING:-

IF/ ELSE STATEMENT:-

The if – else statement is used to carry out a logical case and then take one of
the two possible actions depending upon the outcome of the case whether it’s
true/false.

The else portion of if/ else statement is optional thus the simplest general form
is:-

If(condition)

Statement;

14
Where the condition must place in parenthesis. In this form statement will be
expected only if the expression has a non-zero value i.e if the expression is true
otherwise it is ignored.

The general statement form of if statement with else is,

if (condition)

Statement 1;

else

Statement 2;

If the condition is true, statement 1 will be executed otherwise statement 2 will


be executed.

BREAK STATEMENT:-

The break statement is used to terminate loop or to exit from a switch. It can be
used within for loop, while loop or switch. Break statement is written simply as
break.

CONTINUE STATEMENT:-

The continue statement is used to bypass the remainder of the current pass. A
continue statement can be used within while loop , do-while loop or for
statement.

LOOPING:-

WHILE LOOP:-The while statement is used to carry out looping operation in


which a group of statement is executed repeatedly until some condition has been
satisfied.

The general form of while loop:-

15
{
Statements;
}
The statements will be executed repeatedly as long as the expression
is true. The statement can be simple or compound though it is usually
a compound statement.

DO – WHILE LOOP:-

When a loop is constructed using the while statement. The test for
continuation of the loop is carried out at the beginning of its path,
Sometime however it is desirable to have a loop with the test for
continuation at the end of each pass. This can be accomplished by
means of do- while statement. The general form of Do while
statement is

do{
Statements;
}
while(condition);
Here the statement will be exhibited rapidly as long as the value of the condition
is true i.e. non zero. The statement can be either be simple or
compound .Though most of the application will required to be a compound
statement.

FOR LOOP:-

16
The for statement is the third and perhaps the most common loop statement in c.
The statement include an expression that specifies an initial value of an index ,
another expression that determines whether or not the loop is continued and
third expression that allows the index to be modified at the of its pass.

The general form

for(exp 1;exp 2;exp 3)


{
Statements;
}
Where exp 1 is used to initialize some parameter and exp 2 represent a
condition that must be true for the loop continuation and exp 3is used to alter
the value for the parameter initially assigned.

FUNCTIONS

A function is a self-content program segment that carries out some specific well
defined tasks. Every C program consists of one or more function. One of this
must be called main. If a program contains multiple functions their definition
may appear in any order. Though they must be independent of one another i.e.
one function definition cannot be embedded within another.

DEFINING A FUNCTION:

A function definition has two principle components. The first line includes the
argument declaration and body of the function. The first line of a function
definition contains the type specification of the value return by the function
followed by the function name and optionally a set of argument. A set of

17
arguments separated by commas and enclosed in parenthesis. The general form
of the first line is:

[data type name (type1 arg1, type2 arg2,……..,typen argn)]

where data type represents the data type of the item return by the function.
Name represents the function name and type1, type2…....typen represent the
data types of the argument and arg1, arg2………….,argn are the argument.

FUNCTION PROTOTYPE:

The programmer defined function has always preceeded main. Thus when this
program are compiled the programmer defined function has been defined before
the first function access. However many programmer prefer the top down
approach in which main ahead of the programmer defined function.

In such situation the function access will precede the function definition. This
can be confusing to the compiler unless the compiler is fast alerted to the fact
that the function in access will define later in the program. A function prototype
is used for this purpose. The general form of function prototype is:

int big( int a, int b);

void main()

RECURSION

It is a process by which a function calls itself repeatedly until some specified


conditions are satisfied. The process is used for repetitive computation in which
each action is stated in terms of the previous result. Recursive functions are very

18
useful to solve many mathematical problems, such as calculating the factorial of
a number, generating Fibonacci series, etc.

Syntax:

recursive_function()

if base_case = true;

return;

else

return code_for_recursion;

The recursive function or method has two main parts in its body, i.e., the base
case and the recursive case. While the recursive method is executed, first, the
base case is checked by the program. If it turns out true, the function returns and
quits; otherwise, the recursive case is executed. Inside the recursive case, we
have a recursive call that calls the function inside which it is present.

Advantages of recursion

 The code may be easier to write.

 Reduce unnecessary calling of function.

 Recursion reduces the length of code.

Disadvantages of recursion

19
 Recursive functions are generally slower than non-recursive function.
 It may require a lot of memory space to hold intermediate results on the
system stacks
 It is not more efficient in terms of space and time complexity.

There are two types of recursion in the C language:

 Direct Recursion: Direct recursion in C occurs when a function calls itself


directly from inside.

 Indirect Recursion: Indirect recursion in C occurs when a function calls


another function and if this function calls the first function again.

ARRAY
In C many applications required the processing of multiple data item that have
common characteristics. In such situation it is often convenient to place the data
items into an array where they will share the same name. The individual data
items can be characters, integers, floating point integers etc. However, they
must all be the same type and the same storage class. Each array element is
referred to by specifying the array name followed by one or more subscript with
each subscript enclosed in square bracket. Each subscript must be expressed as
an non negative integer in a n element array.

Array elements are:

x[0],x[1],x[2],………………………x[n-1]

The number of subscripts determines the dimensionality of array.

20
Array in C programming language is a collection of fixed size data belongings
to the same data type. An array is a data structure which can store a number of
variables of same data type in sequence. These similar elements could be of
type int, float, double, char etc.

Advantage of Arrays in C:

 Using array, we can aggregate N variables of same data type in a single


data structure.
 We can access any element of array using array name and index.
 Certain algorithms can be easily implemented using array like searching
and sorting, finding maximum and minimum elements.

Disadvantage or limitation of array:

 Array is Static Data Structure. We cannot change the size of array in run-
time.
 We must know in advance that how many elements are to be stored in
array.
 Only elements of same data types can be stored in an array. We cannot
store elements of multiple data types in a single array.

21
MATLAB
Introduction: It is a software package for high performance numerical
computation and visualization. It provides an interactive environment with
hundreds of building functions fop technical computation, graphics and
animation. It also provides easy extensibility with its own high level
programming language. The name of MATLAB stands for "matrix laboratory".

MATLAB Windows: On almost all system MATLAB works through three


basic windows which are -
1) MATLAB Desktop: It is a desktop where MATLAB put us when we
launch it. The MATLAB desktop by default consisting the following sub
windows:
a. Command window: This is the main window. It is characterized
by MATLAB >>. When we launch the application program
MATLAB put us in this window. All command windows,
including those for running users run within program.
b. Command direct we pane: This pan is located on the left of the command
window in the default MATLAB desktop layout. This is where all of your files
from current directory are listed.
c. Details pane: Just below the command dined us pane is details
Pane.
d. Workspace pane: This windows list all variables that we have
generated as far and shows their type and size.
e. Command history pane: All command types in a MATLAB from in the
command will get recorded even across multiple sessions.

File types: MATLAB can read and write several types of files. However, there
are mainly five different types of files for storing the data on programs. M-file
standard ASCIL text file with a top M-extension.

22
There are two types of this file: 1) Script file

2) Function file
Most programs to write in MATLAB are saved in M-files. All build in function
in MATLAB are in files.

MAT file: MAT files are binary data files with a dot(.)-MAT extension MAT-
file are created by MATLAB when we save data with save command.

Fig file: Fig files are binary files with dot fig extension. That can be open again
in MATLAB as figure.

P-file: P-files are compiled M-files with a dot(.) P extension. That can be
executed MATLAB directly.

MEX-file: MEX files are MATLAB Fortran turn, C and Java program with a
dot(.) MEX extension to the file name.

MATLAB is a platform a platform independent program. One of the best


features of MATLAB is its platform independent. Program written in MATLAB
language work exactly the same on all computers.

Arithmetic operation in MATLAB:


i) +
ii) –
iii) *
iv) /
v) \
vi) ^

23
Numbers in MATLAB:

There are three kinds of numbers used in MATLAB. They are:

i) Integers

ii) Real

iii) Complex number

Integers are extended without decimal point and numbers with decimal point are
known as real number. Variables realmin and realmax denotes the smallest and
the largest positive real number in MATLAB. Complex number in MATLAB.
Complex number in MATLAB is represented in rectangular form. The

imaginary unit √-1 is denoted by i or j.

i = 0 + 1.000 i

In addition to classes of number mentioned above MATLAB has three variables


representing the non-numbers.

 -Inf
 Inf

 NaN

There are IEEE representations of negative and positive infinity. Na stands for
not a number. Saving and loading our works. All variables used in current
MATLAB session are saved in a work space. We can view the content of the
file workspace by clicking on file in the tool bar next selecting show workspace
or we can also check the content of the workspace by typing ‘Whos’ in the
command window.

24
INTRODUCTION TO LATEX

The generally used documents such as project reports, notices, internal notes
etc. in any technical institute are expected to be submitted in a standard
specified format. The commonly used editing tools for this purpose are
Microsoft Word, notepad, wordpad, etc.
Taking into consideration various formatting constraints namely alignment, font
styles, paragraphs, sections, subsections, etc. becomes a bit tedious using MS
Word or other tools. Also maintaining the subscripts and superscripts to obtain
the various mathematical equations becomes difficult and time consuming.
To overcome this drawback we have LATEX, a documentation preparation
system that enables the document writer to concentrate on the contents of their
text, without bothering too much about the formatting of it.
An Introduction to Latex
LATEX is a document preparation system for high-quality typesetting. It is
most often used for medium-to-large technical or scientific documents but it can
be used for almost any form of publishing.
LATEX is not a word processor. LATEX is based on the idea that authors
should be able to focus on the content of what they are writing without being
distracted by its visual presentation. In preparing a LATEX document, the
author specifies the logical structure and lets the LATEX system worry about
the presentation of these structures. It therefore encourages the separation of
layout from content while still allowing manual typesetting adjustments where
needed.
LATEX is based on Donald E. Knuth’s TEX typesetting language or certain
extensions. LATEX was first developed in 1985 by Leslie Lamport.

WHY LATEX?

25
What you see is what you get (WYSIWYG) programs make it easy to put text
wherever you want in whatever size and style of type you want, i.e.,
WYSIWYG programs offer visual design.
The visual design is fine for short, simple documents like letters and memos.
The visual design is not good for more complex documents such as scientific
papers. For this purpose, we use LATEX that offers logical design.
LATEX is intended to provide a high-level language that accesses the power of
TEX. LATEX comprises a collection of TEX macros and a program to process
LATEX documents. Because the TEX formatting commands are very low-level,
it is usually much simpler for End-users to use LATEX.
As LATEX is distributed under the terms of the LATEX Project Public License
(LPPL), LATEX is free software.

Required Parts of LATEX Input File


A few commands must appear in every LATEX input file in a certain order.
They are:
\documentclass{classname}
\begin{document}
\end{document}
The document style has a required argument stylename to select an overall type-
setting style for the document; the one normally used is article (there are also
book, report, letter, and memo). It also has an optional argument to select 11pt
or 12pt normal type 4 size (10pt is the default size). The actual text of user
document and associated commands go between the begin and end commands.
Customizing Latex
There are situations where LATEX does not provide a command or
environment that matches user needs, or the output produced by some existing
command may not meet user requirements. To add your own commands, use
\newcommand{name}[num]{definition}

26
The command requires two arguments: the name of the command you want to
create, and the definition of the command. The num argument in square
brackets is optional.

27
CONCLUSION

At the end of this internship we have learnt to do various types of coding


language. By doing this we have increased our knowledge about the theory
lectures of programming and also we have widen our knowledge about C
program. We have also ensured that the guidelines set by our lecturer are
followed during this internship period.

Matlab is more than a calculator. It’s a powerful programming environment.


Have reviewed concept of an m file, decision making in matlab, examples etc.

LATEX is a document preparation system for high-quality typesetting. It is


most often used for medium-to-large technical or scientific documents but it can
be used for almost any form of publishing.

28
REFERENCES

 Yashavant Kanetkar, Let us C, Authentic Guide to C


programming Language, 17th edition.
 Rudra Pratap, Getting Started with Matlab, 17th edition
 A document preparation system of latex
 http://tug.org/tutorials/tugindia/
 http://miktex.org

29

You might also like