CTSD Project 2
CTSD Project 2
Vasya got interested by the fact that some divisibility rules resemble each other.
In fact, to check a number's divisibility by 2, 4, 5, 8 and 10it is enough to check fulfilling
some condition for one or several last digits. Vasya calls such rules the 2-type rules.
If checking divisibility means finding a sum of digits and checking whether the sum
is divisible by the given number, then Vasya calls this rule the 3-type rule (because it
works for numbers 3 and 9).
If we need to find the difference between the sum of digits on odd and even
positions and check whether the difference is divisible by the given divisor, this rule is
called the 11-type rule (it works for number 11).
In some cases, we should divide the divisor into several factors and check whether
rules of different types (2-type, 3-type or 11-type) work there.
CONCEPTS USED:
1. function:
Function with arguments and one return value means both the calling function
and called function will receive data from each other. It’s like a dual communication.
SYNTAX:
Function declaration : int function ( int );
Function call : function( x );
Function definition:
int function( int x )
{
statements;
return x;
}
1
2.CONDITION STATEMENTS:
if else if ladder:
common programming construct that is based upon nested ifs is the if-else-if
ladder. It looks like this. The conditional expressions are evaluated
from the top downward. As soon as a true condition is found, the statement associated
with it is executed, and the rest of the ladder is bypassed.
SYNTAX:
if (Condition1)
Statement1;
else if(Condition2)
Statement2;
else if(ConditionN)
StatementN;
else
Default_Statement;
2
3.LOOPS:
While loop:
SYNTAX:
while (condition) {
statements;
3
AIM
Advantages: -
The advantage of this project is we can find all divisibility rules of a given
number and its types.
Disadvantages: - This code can’t be used for decimal values .
Future Enhancements: -
We'll develop the programs so that the output will be more detailed.
We can find whether a number is an even or odd also can be used for prime numbers.
4
SYSTEM REQUIREMENTS
➢ SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : C programming language
Operating System: Windows Xp.
➢ HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as follows:
RAM: 16 Gb
5
CLASS DIAGRAM
6
7
ALGORITHM
Step 1: start
step 5: s=s/10
step 6: add+=rem
step 9: temp=0, r
while(d!=0)
8
step 20: print 3-type
9
IMPLEMENTATION
#include<stdio.h>
int add=0,rem=0;
rem=s%10;
s=s/10;
add+=rem;
return add;
int main(){
int b,d;
int r, temp=0;
if (b==2){
while(d!=0){
r=d%b;
d=d/b;
temp=temp*10+r;
d=temp;
10
if((d%2==0) ||(d%5==0))
printf("2-type\n");
printf ("1");
printf("3-type");
printf("2-type");
printf ("2");
printf("6-type");
printf("2-type");
printf ("3");
11
printf("3-type");
else if ((d%11)==0){
printf("11-type");
else
printf("7-type");
12
INTEGRATION AND SYSTEM TESTING
OUTPUTS
Screenshots:
13
CONCLUSION
14