Computer Science, asked by Anonymous, 7 months ago

write a program to input palprime
number using scanner class only. ​

Answers

Answered by dhruvsh
1

Answer:

Ok, so I think I'll be able to write down the syntax, however you'll have to see if this will actually work or not on the computer.

I'm gonna write the general syntax, so it can be written down in any language further.

Program:

class scanner

{

private

unsigned long int num;

public:

void getdata();

void show();

};

void scanner::getdata()

{

cout<<"Please enter the number:";

cin>>num;

}

void scanner::show()

{

unsigned long int n,temp=0;

int counter = 1,dn;

for (int j = 2 ; j<num;j++)

{ if(num%j==0)

{ counter=0;

}

}

if(counter==0)

{ cout<<"\n The number is prime, however checking if it's a pallindrome too or not? ";

}

else

{cout<<"\nThe number is not prime, program stopped.";

n=num;

while(n!==0)

{ dn=num%10;

temp=temp*10+dn;

n=n/10;

}

if (temp==num)

{

cout<<"\nThe number is also pallindrome.";

}

else

{ cout<<"\n The number isn't pallindrome, the program is now stopped.";

}

}

void main()

{

clrscr();

scanner number;

number.getdata();

number.show();

getch();

}

That's it ! I've written up this C++,but you can use any other langauage too, the control flow or the algorithm remains the same.

Thank you so much !

Hope this helps you !

。◕‿◕。

Answered by ghoshdhruba2
0

Answer:

sorry bro...today i cant talk due to network problem

Similar questions