Software Project
Lab -1
Name : Md. Arif Hasan
Roll : BSSE 1112
Superviser : Nadia Nahar
01
“ Code
Categorization ”
Project Name:
02
What is Code categorization ?
Code categorization can be defined as separating some
codes in basis of some predefined characteristics.
These characteristics are determined using a control flow
and data flow graph .
03
Code-2 :
#include<bits/stdc++.h>
using namespace std;
int main()
{
Int x , y , ans;
cout<<"Enter two integers:";
cin>>x>>y;
ans = x + y;
cout<<ans;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a, b, sum;
cout<<"Enter two integers:";
cin>>a>>b;
sum = (a+b);
cout<<sum;
return 0;
}
Code- 1 :
04
Code-4 :
1. #include<bits/stdc++.h>
2. using namespace std;
3. void sum(int x,int y)
4. {
5. int ans= x+y;
6. cout<<"The sum is :"<< ans;
7. }
8. int main()
9. {
10. int a, b;
11. cout<<"Enter two integers:";
12. cin>>a>>b;
13. sum(a,b);
14.}
1. #include<bits/stdc++.h>
2. using namespace std;
3. int main()
4. {
5. int a, b, sum;
6. cout<<"Enter two integers:";
7. cin>>a>>b;
8. sum = (a+b);
9. cout<<sum;
10. return 0;
11. }
Code- 3 :
05
Motivation:
❖ Found difficult to categorize my codes manually.
❖ Takes a vast amount of times to find same type of codes
from a cluster of codes.
❖ To Reduce plagiarism .
06
Overview of the project :
● Take some C/C++ files as a input .
● I will represent those codes as a data flow and control
Flow graph.
● Comparing those data flow and control flow graph, i
will categorize those C/C++ codes .
07
Background Study
i) Control Flow Graph
ii) Data flow Graph
iii) Abstract Syntax Tree
08
Control Flow Graph : A control flow graph is a graphical representation of control flow or
computation during the execution of a program.It is a process oriented and directed graph.
1. int main()
2. {
3. int a=2,b=3;
4. int sum=(a+b);
5. if( sum > 0)
6. {
7. cout<<”Ans is: “<<sum;
8. }
9. else if (sum<0)
10. {
11. cout<<”Negative ans”;
12. }
13. else
14. { cout<<” Not valid”;}
15. }
3
4
5
14
11 7
9
F T
T
F
09
Data Flow Graph : A data flow graph is a directed graph in which
assignments and references to variables are represented by the nodes .
1. int main()
2. {
3. int a=20 ;
4. if(a>10)
5. { cout<<” a is less than 10”; }
6. else
7. { cout<<”a is greater than 10”; }
8. return 0;
9. }
3
4
6
7
5
10
Progress:
I can count the variable declared in a code, can detect all the
variables with their line numbers . I can also detect all the functions with their
return type from this code.
The github codes link:
i)Count of variables : https://github.com/Md-Arif-Hasan/SPL-1/blob/master/Count%20of%20variables%20--%202%20.cpp
ii) Detect variables : https://github.com/Md-Arif-Hasan/SPL-1/blob/master/Detect%20Variables.cpp
iii) Detect functions and all variables with line no:
https://github.com/Md-Arif-Hasan/SPL-1/blob/master/variable%20and%20function%20detection(%20with%20struct).cpp
11
PROGRESS:
i)Count of variables :
ii) Detect variables :
12
iii) Detect functions and all variables with line no:
13
Future Plan :
i) Making a data flow graph for each variables using these line
numbers.
ii) Making a control flow graph by using conditions , line numbers,
variables and functions.
iii) Represent the graphs to their corresponding matrix.
iv) Compare these matrices and determine whether they are similar
or not.
14
THANK YOU
15

Control flow Graph

  • 1.
    Software Project Lab -1 Name: Md. Arif Hasan Roll : BSSE 1112 Superviser : Nadia Nahar 01
  • 2.
  • 3.
    What is Codecategorization ? Code categorization can be defined as separating some codes in basis of some predefined characteristics. These characteristics are determined using a control flow and data flow graph . 03
  • 4.
    Code-2 : #include<bits/stdc++.h> using namespacestd; int main() { Int x , y , ans; cout<<"Enter two integers:"; cin>>x>>y; ans = x + y; cout<<ans; return 0; } #include<bits/stdc++.h> using namespace std; int main() { int a, b, sum; cout<<"Enter two integers:"; cin>>a>>b; sum = (a+b); cout<<sum; return 0; } Code- 1 : 04
  • 5.
    Code-4 : 1. #include<bits/stdc++.h> 2.using namespace std; 3. void sum(int x,int y) 4. { 5. int ans= x+y; 6. cout<<"The sum is :"<< ans; 7. } 8. int main() 9. { 10. int a, b; 11. cout<<"Enter two integers:"; 12. cin>>a>>b; 13. sum(a,b); 14.} 1. #include<bits/stdc++.h> 2. using namespace std; 3. int main() 4. { 5. int a, b, sum; 6. cout<<"Enter two integers:"; 7. cin>>a>>b; 8. sum = (a+b); 9. cout<<sum; 10. return 0; 11. } Code- 3 : 05
  • 6.
    Motivation: ❖ Found difficultto categorize my codes manually. ❖ Takes a vast amount of times to find same type of codes from a cluster of codes. ❖ To Reduce plagiarism . 06
  • 7.
    Overview of theproject : ● Take some C/C++ files as a input . ● I will represent those codes as a data flow and control Flow graph. ● Comparing those data flow and control flow graph, i will categorize those C/C++ codes . 07
  • 8.
    Background Study i) ControlFlow Graph ii) Data flow Graph iii) Abstract Syntax Tree 08
  • 9.
    Control Flow Graph: A control flow graph is a graphical representation of control flow or computation during the execution of a program.It is a process oriented and directed graph. 1. int main() 2. { 3. int a=2,b=3; 4. int sum=(a+b); 5. if( sum > 0) 6. { 7. cout<<”Ans is: “<<sum; 8. } 9. else if (sum<0) 10. { 11. cout<<”Negative ans”; 12. } 13. else 14. { cout<<” Not valid”;} 15. } 3 4 5 14 11 7 9 F T T F 09
  • 10.
    Data Flow Graph: A data flow graph is a directed graph in which assignments and references to variables are represented by the nodes . 1. int main() 2. { 3. int a=20 ; 4. if(a>10) 5. { cout<<” a is less than 10”; } 6. else 7. { cout<<”a is greater than 10”; } 8. return 0; 9. } 3 4 6 7 5 10
  • 11.
    Progress: I can countthe variable declared in a code, can detect all the variables with their line numbers . I can also detect all the functions with their return type from this code. The github codes link: i)Count of variables : https://github.com/Md-Arif-Hasan/SPL-1/blob/master/Count%20of%20variables%20--%202%20.cpp ii) Detect variables : https://github.com/Md-Arif-Hasan/SPL-1/blob/master/Detect%20Variables.cpp iii) Detect functions and all variables with line no: https://github.com/Md-Arif-Hasan/SPL-1/blob/master/variable%20and%20function%20detection(%20with%20struct).cpp 11
  • 12.
    PROGRESS: i)Count of variables: ii) Detect variables : 12
  • 13.
    iii) Detect functionsand all variables with line no: 13
  • 14.
    Future Plan : i)Making a data flow graph for each variables using these line numbers. ii) Making a control flow graph by using conditions , line numbers, variables and functions. iii) Represent the graphs to their corresponding matrix. iv) Compare these matrices and determine whether they are similar or not. 14
  • 15.