Break Continue
It pass the whole steps of the block It pass the current iteration of the loop
It is applicable for any block-Loops,switch statement It is applicable for loops only
etc
Example:
#include<stdio.h>
#include<stdio.h> int main(){
int main(){ int n = 1 while (n<10){
while (n<10){ if(n=5){continue;}
if(n=5){break;} printf(“%d”,n);
printf(“%d”,n); }}
}
} OUTPUT:
1234678910
OUTPUT:
1234
COMPILATION ERROR : It happens during the Compilation of the code from Programming Language to
Machine Language.
Redeclaration Error in Compilation error: It happens when a variable is redeclared with another
datatype Scope.
ASCII VALUES IN C: 65-90 ABCD….. 97 to 122 abcd…..
Lowering in C: ch = tolower(ch)
RECURSION
Recursion is the process of executing the fuction in its own block and it continues until the certain
condition is satisfied. It works on the principle of Last put first out.
In recursion the last function only executes the final return otherwise other superior/earlier functions
return the recursion result.
Escape Characters:
\r (Carriage return) ------------ goes to the initial position of the string
STRINGS
getche() ---- It asks the input and immediately prints it but when I say n = getche(n) it stores
ascii value i.e in order to convert the ASCII to real value we subtract with ‘0’ for (0-9).
N = getche()
N= N-1;
ARRAYS
Strings are arrays in c and they cannot be assigned directly using ‘=’ sign so we use strcpy()
function.
Array of the structure can be passed directly using ‘=’ sign
But Array of other datatype is not possible using ‘=’ sign
FINDING THE HCF AND LCM:
Euclidean Problem :
a,b where a should be b greater than b.
int temp ;
while(b!=0){
temp = b;
b = a%b;
a= temp}
printf(“%d”,b)
Pointers
Call by Value
If we only pass the values of the variable to the out function, the process is called call by value.
Call By reference
If we pass the variable value with the reference of its address then this process is called call by
reference.
String and Pointer
In c programming %s directly dereference the memory address. Also it reads the characters until
the end of the string’\0’ is not reached.
Example:
char k[] = "ahehhe";
printf("%s",k); Here the output is ahehhe
printf("%c",*k); %c doesn’t dereference and reads one char only
Similarly if :
char *s = "Hello";
printf("%s",s); Here the s is the pointer to the char ‘H’ and 5s reads until ‘\0’
Assigning the pointer directly to the string:
*pt = “Hello”;
Here the pointer is assigned to the 1st character of string and it is in the text segment
memory (Read Only purpose memory).
STRING :
%[^\n]- Read every thing except a newline
In C programming we can’t compare two strings directly instead we use strcmp(str1,str2);
Strcmp() subtracts the ASCII values of two strings and if it is zero then two strings are equal.
STRUCTURE:
No of elements in an Struct-Array: sizeof(struct_array)/sizeof(struct_array[0])
FILE HANDLING
The binary mode converts the characters and integers into their respective binary code
For example : integer 52 -> 00000000 00000000 00000000 00110100 (4 bytes)
Char ‘4’ = 52 ASCII = 00110100 (1Byte)
Signed = we can input both -ve and +ve
Unsigned = =ve numbers only
STORAGE CLASS
Creating the function in another file and implementing it in a main file:
STATIC Storage class:
For variable: It retains the previous value of the variable whenever a function is called.
Static Function: It limits the function scope within the file.We can’t use this function in
another file after Linking two files. For a Same File The static Function works similar as
the normal function without static keyword.
Using:
#ifndef MY_FUNCTIONS_H : Header Inguard
Here inguard checks Student.h has already
on the main file so if won’t create the another header
File.
RANDOMNESS
We should import time.h and stdlib.h
srand(time(0)) -- Sets the seeds for the random numbers
float a = rand()/RAND_MAX - Rand_max = 32767
QUESTIONS
QN) What is an array?How it differ from an Ordinary Variable?What are restrictions in an array?
Array is the collection of elements of same datatype stored in a continuous memory
location.
Array differ from an ordinary variable as it is the collection of items,not just one but
many
Restrictions:
o Fixed size,(Cannot be resized later)
o Same Elements of the defined data_type
o Accessing element beyond boundary is prohibited
o Can only pass the memory address of the element to the function (Entire array is
not permittable)