c
c
What is Enum.
An enumeration is a data type that consists of a set of named values that represent integral
constants, known as enumeration constants.
Or
It gives opportunity to invent own data-type and define what values variable of this
datatype can take
It increases the redeability of the program.
For clearence refer Sourabh Shukla
Call by reference in C
In call by reference, the address of the variable is passed into the function call as the actual
parameter.
Call by value in C
o In call by value the value of the actual variable is passed in the function call in
the call by value method.
Call by
Call by Value
Reference
Constructor :-
Constructor is a member function of a class that is executed whenever we create a new object of the
class.
The name of the constructor is same as the name of the class
Constructor has no return type
Specialty:-
A constructor is a special method that is used to initialize newly created object and is called implicitly,
just after the memory is allocated for the object.
It is not mandatory for the coder to write a constructor for the class
When there is no constructor defined in the class by the programmer compiler implicitly provide a
default constructor for the class.
By default constructor made by compiler if we don’t make it
Box()
{ //no code inside the body
}
Program
Public Class Box
{
Private int l,b,h;
Public Box()
{
l=10; b=8; h=4;
}
Public Box(int L, int B, int H)
{
l=L; b=B;h=H;
}
Public static void main(static [] args)
{
Box b1=new Box();
Box b2 =new Box(20,15,5);
}
#include<stdio.h>
int main()
int i = 10;
static int x = i;
if (x==i)
return 0;
#include <string.h>
int main()
return 0;
Output:
GEEKS size = 6
GEEKS length = 5
Explanation:
sizeof() function returns the size of the string including null character while strlen() function
returns length of the string excluding null character.
While loop
After the body of a loop is executed, the control again goes back to the beginning, and the
condition is checked. If it is true, the same process is executed until the condition becomes
false. Once the condition becomes false, the control goes out of the loop.
In a while loop, if the condition is not true, then the body of a loop will not be executed, not
even once.
In the do-while loop, the body of a loop is always executed at least once. After the body is
executed, then it checks the condition. If the condition is true, then it will again execute the
body of a loop. Otherwise, the control is transferred out of the loop.
While loop checks the condition first and then executes the statement(s), whereas do
while loop will execute the statement(s) at least once, then the condition is checked.
the difference between for loop and while loop is that in for loop the number of
iterations to be done is already known and is used to obtain a certain result whereas
in while loop the command runs until a certain condition is reached and the statement
is proved to be false.
Where is C used?
C programming finds its application across industries and can be used in many ways, such as:
In embedded systems
To produce compilers
In IoT-related applications
Most of the operating systems are written in the C/C++ languages. These not only include
Windows or Linux (the Linux kernel is almost entirely written in C), but also Google Chrome OS,
RIM Blackberry OS 4.
Linked List
o Linked List can be defined as collection of objects called nodes that are randomly stored
in the memory.
o A node contains two fields i.e. data stored at that particular address and the pointer which
contains the address of the next node in the memory.
o The last node of the list contains pointer to the null.
A circular linked list is a variation of a singly linked list. The only difference between
the singly linked list and a circular linked list is that the last node does not point to
any node in a singly linked list, so its link part contains a NULL value. On the other
hand, the circular linked list is a list in which the last node connects to the first
node, so the link part of the last node holds the first node's address.
Static block is a set of instructions that is run only once when a class is loaded into
memory
Variable
* which belongs to the class and initialized only once at the start of the execution.
*Don’t need any object to call
*Initialized only once
Method
the methods in Java that can be called without creating an object of class.
Functions
A function is a group of statements that together perform a task.
Pointer
The Pointer in C, is a variable that stores address of another variable.
Typecasting
o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation
Object
Any entity that has state and behavior is known as an object. For example, a chair, pen,
table, keyboard, bike, etc. It can be physical or logical.
Class
A class can be defined as a blueprint from which you can create an individual
object. Class doesn't consume any space.
Suppose we have a chocolate mould which have 2 characteristic shape and size. By
using that mould we can have an choclate which would have the same characteristics
as mould even can do different experiment in to that too like adding thea almonds and
penuts into choclate or changing the colour of choclate
So mould is the class and it will define the attribute of the resultant chocolate
Chocolate is the object and created based on the class chocolate mould