0% found this document useful (0 votes)
4 views15 pages

ComputingLab DroneTraining1

Uploaded by

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

ComputingLab DroneTraining1

Uploaded by

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

Basics of Computing

Computers and Programming


▪ A computer is a machine that can store and
process information, and can be
programmed to perform a wide range of
tasks.
▪ computers are not designed to do just one job.
▪ Computers can do such a wide variety of
things because they can be programmed.
▪ A program is a set of instructions that a
computer follows to perform a task.
Software and Hardware
▪ Programs are commonly referred to as software.
▪ Ex. MS Word, PDF reader, media player etc.
▪ All of the software that we use to make our
computers useful is created by individuals working as
programmers or software developers.
▪ The term hardware refers to all of the physical
devices, or components, that a computer is made of.
▪ The central processing unit (CPU)
▪ Main memory
▪ Secondary storage devices
▪ Input devices
▪ Output devices
How a Computer Store Information
▪ A computer’s memory is divided into tiny storage
locations known as bytes.
▪ One byte is only enough memory to store a letter of
the alphabet or a small number.
▪ Each byte is divided into eight smaller storage
locations known as bits (binary digit).
▪ Bits are tiny electrical components that can hold
either a positive or a negative charge.
▪ Bits resemble tiny switches that can be either on or
off. We can think of a positive charge as a switch in
the on position, and a negative charge as a switch in
the off position.
Programming Languages
▪ Machine Language : Machine Language are written
using 0’s and 1’s only. Computers can understand and
execute programs that are written in machine
language. Difficult to write for human.
▪ Assembly language: Assembly language is a low-
level programming language that uses human-
readable mnemonic codes to represent machine
instructions.
▪ Each High-level language allows us to create
powerful and complex programs without knowing
how the CPU works, and without writing large
numbers of low-level Instructions. High-level
languages use words that are easy to understand.
Compilers and Interpreter
▪ Compiler is a program that translates a high-level
language program into a separate machine language
program called executable. Ex: C, C++, Java
▪ The executable (machine language program) can
then be executed by CPU any time it is needed.
▪ Interpreter: Is a program that both translates and
executes the instructions in a high-level language
program.
▪ An interpreter reads each individual instruction in
the program, it converts it to machine language
instructions and then immediately executes them.
Ex. Python, Shell Script, Tcl/Tk.
‘C’ Programming Language
▪ C was originally developed in the 1972s, by Dennis
Ritchie at Bell Telephone Laboratories, Inc.
▪ C is a High level , general –purpose structured
programming language.
▪ Instructions of C consists of terms/ keywords that are
very close to English such as if, else, for ,do and while
▪ C contains certain additional features that allows it to be
used at a lower level.
▪ This allows C to be used for system programming as
well as for applications programming
Identifiers

• An identifier is a word used by a programmer to


name a variable , function, or label.
• A 'C' program consist of two types of elements ,
user defined and system defined. Identifiers is
nothing but a name given to these elements.
• Identifiers consist of letters and digits, in any
order, except that the first charecter or lable.
• Identifiers consist of letters and digits if any
order, except that the first character must be
letter.
• Both Upper and lowercase letters can be used.
Keywords
• Keywords are nothing but auto double int struct
system defined
identifiers. break else long switch

• Keywords are reserved case enum register typedef


words of the language.
• Cannot be used by the char extern return union
programmer as variable or
constant names const float short unsigned

• C is case sensitive, it
continue for signed void
means these must be used
as it is. default goto sizeof volatile
• 32 Keywords in C
Programming do if static while
Variables

• A variable is nothing but a name given to a


storage area that our programs can manipulate.
• The name of a variable can be composed of
letters, digits, and the underscore character.
• It must begin with either a letter or an
underscore. Upper and lowercase letters are
distinct because C is case-sensitive.
• Not permitted: commas, blanks, no special
symbol other than an underscore.
• Usually maximum 31 characters (alphabet,
digits). Again depends upon compiler.
Variables

• Each variable in C has a specific type, which


determines the size and layout of the variable's
memory; the range of values that can be stored
within that memory.
• There are following basic variable types −
– char (1B) Typically a single octet(one byte).
– int (4B).
– Long (8B)
– Float (4B) A single-precision floating point value.
– Double (8B) A double-precision floating point value.
First C Program

• #include <stdio.h>
• int main ()
• {
• printf(“Hello world\n”);
• return (0);
• }
Variable Assignment

• #include <stdio.h>
• int main ()
• {
• int num1;
• int num2;
• int sum;
• num1 = 12;
• num2 = 13;
• printf(“Value of num1=%d, num2=%d, sum=%d \n”,
num1, num2, sum);
• return (0);
• }
Addition

• #include <stdio.h>
• int main ()
• {
• int num1;
• int num2;
• int sum;
• num1 = 12;
• num2 = 13;
• sum = num1 + num2;
• printf(“Value of num1=%d, num2=%d, sum=%d \n”,
num1, num2, sum);
• return (0);
• }
Taking values from keyboards

• #include <stdio.h>
• int main ()
• {
• int num1;
• int num2;
• int sum;
• printf(“Please enter values for num1 and num2 \n”);
• scanf(“%d %d”,&num1, &num2);
• sum = num1 + num2;
• printf(“Value of num1=%d, num2=%d, sum=%d \n”,
num1, num2, sum);
• return (0);
• }

You might also like