the whole program is like this :
int flag = 1;
for ( i=2;i<1000;i++)
{
for( j=2;j<=i;i++)
{
if(i%j==0)
{
flag++;
}
}
if(flag<=2)
{
cout<<i<<endl;
}
flag = 0;
}
finish
The above post might have some...
User Profile
Collapse
-
the above one seems to be quite difficult to understand
here is a very simple logic.
define an integer flag to keep track and initalize it.
int flag = 1;
now start a loop from starting no. i.e 2 till half of the ending no. i.e 500 (half of 1000) because no number greater than 500 would be able to devide 1000 exactly.
like this :
for(i=2;i<=500; i++)
then start...Leave a comment:
-
thanks for the links
they are really very helpful
thanks and regards
shamikLeave a comment:
-
serial port communication in LINUX
hii friends
does anybody know how to do serial communication (through) serial port in linux using c++?
I am using redhat-9. it would be better if someone can provide with eg. codes of client and server to send and recieve data.
please tell me step by step procedure.
regards
shamik -
use gets(address) instead of cin>>address
and puts(address) instead of cout<<addressLeave a comment:
No activity results to display
Show More
Leave a comment: