Basic Computer Programming in C, Study notes of Computer Programming

Basic Computer Programming in C

Typology: Study notes

2020/2021

Uploaded on 03/24/2021

rajiv-choudhury
rajiv-choudhury 🇮🇳

1 document

1 / 19

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
=>Format specifier – represented by
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
=> Addressof is represented by - &.
=> Operators :-
1. != - Not equal
2.== - equal
3./ - division
4.% - remainder
5.> - greater than
6.< - less than
7.>= - greater than equal to
8.<= - less than equal to
9.& - bitwise and
10. | -bitwise or
11. ^ - bitwise xor (Converts to binary system)
=> Logical Operators
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Basic Computer Programming in C and more Study notes Computer Programming in PDF only on Docsity!

=>Format specifier – represented by

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

=> Addressof is represented by - &. => Operators :-

  1. != - Not equal 2.== - equal 3./ - division 4.% - remainder 5.> - greater than 6.< - less than 7.>= - greater than equal to 8.<= - less than equal to 9.& - bitwise and
  2. | -bitwise or
  3. ^ - bitwise xor (Converts to binary system) => Logical Operators

1.&& - AND operator 2.|| - OR operator X Y AND OR XOR 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 => Conditional operators ? - then : - else => If else Statement:- Syntax = if(Condition){ } Else{ } NOTE- LINE prints the line no. ( printf(“%d”, LINE); ) NOTE -

=>For Loop:- Syntax:- for (initialization; condition ; increment or decrement){ statement; statement; }

Output-

Function:-

Arrays **Note- int n = 6;

a[n]

is invalid location can be written as- &a[1] or (a + 1) the data can be accessed by- a[1] or *(a + 1)

Pointers

Scanf Syntax – scanf(“Format specifer”, variable);

Calloc function It creates dynamic memory in the heap.

 gets(takes the variable of string)- It takes user input from keyboard of a line until the cursor moves to to next line.  puts(takes thevariable of string)- It gives output of the input line given.  strlen()-It return integer value of length of string given in parameter.  strcpy(x,y)-It takes two parameters such that it copies the string from y to x.  strcat(x, y)- It takes two Strings parameter and concatenates them like here it will return x + y.  strcmp(x, y)- It takes two strings as parameter and compares them and return -1, 0 , 1 if x > y, x == y, x > y respectively. 2D array used to store multiple Strings

Defining Macros