What is Computer Programming

Computer

Programming Prerequisite 

  • Basic mathematics
  • Truth tables of AND , OR, NOT
  • If ... then else

C - Compiler

Tokens

  • Identifiers
  • Keywords
  • Constants
  • Strings
  • Operators
  • Special Symbols

Identifiers

C identifiers represent the name in the C program, for example, variables, functions, arrays, structures, unions, labels, etc.

C Keywords

auto double int struct
break else long switch
case enum register typedef
char extern return union
continue for signed void
do if static while
default goto sizeof volatile
const float short unsigned

Variable

A variable is a quantity that may change within the context of a mathematical problem or experiment. Typically, we use a single letter to represent a variable. The letters x, y, and z are common generic symbols used for variables.

Primitive ​

 

  • int (unsigned , unsigned short ,long )

  • char

  • float

  • double

Derived

 

  • array
  • pointer
  • structure
  • union

Data types

Void data type

Format Specifier Type
%c Character
%d Signed integer
%e or %E Scientific notation of floats
%f Float values
%g or %G Similar as %e or %E
%hi Signed integer (short)
%hu Unsigned Integer (short)
%i Unsigned integer
%l or %ld or %li Long
%lf Double
%Lf Long double
%lu Unsigned int or unsigned long
%lli or %lld Long long
%llu Unsigned long long
%o Octal representation
%p Pointer
%s String
%u Unsigned int
%x or %X Hexadecimal representation
%n Prints nothing
%% Prints % character

Format specifier

  • %c
  • %d
  • %f
  • %o
  • %x

Operators

  1. Arithmetic
  2. Logical
  3. Bit-wise
  4. Relational
  5. Assignment
  6. Increment Decrement

Condition

Conditional statements

  • If
  • If ...Else
  • Else if ladder
  • switch statement

If condition

If and else

Loops 

  • for
  • while
  • do .. while

For loop syntax

While loop syntax

Do While loop syntax

Any Electrical / Electronic device

Processor

To control electronic devices do we need to talk in electronic ? 

Binary

 

Binary number

system 

0 AND 1

Maharshi Pingala

Maharshi Pingala

Creator of Binary System

Assembly Program

section	.text
   global _start     ;must be declared for linker (ld)
	
_start:	            ;tells linker entry point
   mov	edx,len     ;message length
   mov	ecx,msg     ;message to write
   mov	ebx,1       ;file descriptor (stdout)
   mov	eax,4       ;system call number (sys_write)
   int	0x80        ;call kernel
	
   mov	eax,1       ;system call number (sys_exit)
   int	0x80        ;call kernel

section	.data
msg db 'Hello, world!', 0xa  ;string to be printed
len equ $ - msg     ;length of the string

C Program

#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}

What is Computer Programming

By Gaurav Polekar

What is Computer Programming

  • 80