write a script to generate n prime no.s?
Answer Posted / venkat
#!c:\perl\bin\perl
$Count = 0;
$pt = 2;
while ( $Count < @ARGV[0] )
{
if (isPrimary($pt))
{
print "$pt\n";
$Count++;
}
$pt++;
}
sub isPrimary
{
$flag = 1;
for ($i=2; $i<=$_[0]/2; $i++)
{
if ($_[0] % $i == 0)
{
$flag = 0;
}
}
return $flag;
}
| Is This Answer Correct ? | 16 Yes | 4 No |
Post New Answer View All Answers
Define dynamic scoping.
Explain chomp, chop, cpan, tk.
explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.
what is the difference between java and cgi?
You want to connect to sql server through perl. How would you do that?
What is the use of "stderr()"?
Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.
What package you use to create a windows services?
What are some common methods to all handles in perl?
Comment on data types and variables in perl.
How to concatenate strings with perl?
Explain cpan?
What are the reasons that cookie server can’t handle multiple connections?
When would `local $_' in a function ruin your day?
What are the advantages of perl programming?