How To Create A Table In Dev C++

Posted By admin On 11.09.21

This video tutorial is about making of a simple table program in c. You can write any table of 1,2 and 3 etc by using for loop. Prerequisite: Symbol Table A Symbol table is a data structure used by the compiler, where each identifier in program’s source code is stored along with information associated with it relating to its declaration. It stores identifier as well as it’s associated attributes like scope, type, line-number of occurrence, etc. Symbol table can be implemented using various data structures like.

  1. How To Create A Table In Dev C++ Interview
  2. How To Create A Table In Dev C Language
  3. How To Create A Table In Dev C++ Program
  4. Create A Table Chart

Prerequisite:Symbol Table

How to create a table in dev c++ download

A Symbol table is a data structure used by the compiler, where each identifier in program’s source code is stored along with information associated with it relating to its declaration. It stores identifier as well as it’s associated attributes like scope, type, line-number of occurrence, etc.

Symbol table can be implemented using various data structures like: Trine 2 complete story 2.01.

  • LinkedList
  • Hash Table
  • Tree

A common data structure used to implement a symbol table is HashTable.

How To Create A Table In Dev C++ Interview

Operations of Symbol table – The basic operations defined on a symbol table include:


Consider the following C++ function:

How To Create A Table In Dev C Language

// Define a global function
int add(int a, int b)
{
int sum = 0;
sum = a + b;
return sum;
}

How To Create A Table In Dev C++ Program

/blockquote>

Symbol Table for above code:

NameTypeScope
addfunctionglobal
aintfunction parameter
bintfunction parameter
sumintlocal

Below is the C++ implementation of Symbol Table using the concept of Hashing with separate chaining:

#include <iostream>
intlineNo;
Node()
next = NULL;
Node(string key, string value, string type, intlineNo)
this->identifier = key;
this->type = type;
next = NULL;
{
cout << 'Identifier's Name:'<< identifier
<< 'Scope: '<< scope
<< 'Line Number: '<< lineNo << endl;
friendclassSymbolTable;
Node* head[MAX];
public:
{
head[i] = NULL;
boolinsert(string id, string scope,
string Type, intlineno);
boolSymbolTable::modify(string id, string s,
{
Node* start = head[index];
if(start NULL)
if(start->identifier id) {
start->type = t;
returntrue;
start = start->next;
}
// Function to delete an identifier
{
Node* tmp = head[index];
if(tmp NULL) {
}
if(tmp->identifier id && tmp->next NULL) {
deletetmp;
}
while(tmp->identifier != id && tmp->next != NULL) {
tmp = tmp->next;
if(tmp->identifier id && tmp->next != NULL) {
tmp->next = NULL;
returntrue;
else{
tmp->next = NULL;
returntrue;
returnfalse;
string SymbolTable::find(string id)
intindex = hashf(id);
return'-1';
while(start != NULL) {
if(start->identifier id) {
returnstart->scope;
}
return'-1'; // not found
boolSymbolTable::insert(string id, string scope,
{
Node* p = newNode(id, scope, Type, lineno);
if(head[index] NULL) {
cout << '
}
else{
while(start->next != NULL)
cout << '
}
returnfalse;
{
asciiSum = asciiSum + id[i];
}
// Driver code
{
string check;
if(st.insert('if', 'local', 'keyword', 4))
else
if(st.insert('number', 'global', 'variable', 2))
else
check = st.find('if');
cout << 'Identifier Is present';
cout << 'Identifier Not Present';
// delete 'if'
cout << 'if Identifier is deleted';
cout << 'Failed to delete';
// modify 'number'
if(st.modify('number', 'global', 'variable', 3))
check = st.find('number');
cout << 'Identifier Is present';
cout << 'Identifier Not Present';
return0;

Create A Table Chart

Output: