Question about Operating Systems

1 Answer

Need code how to write prime number code using c#.net

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Novelist:

    An expert who has written 50 answers of more than 400 characters.

    Governor:

    An expert whose answer gotĀ voted for 20 times.

  • Expert
  • 202 Answers

Try the Following Five Programs

1) Program for Prime Number Generation

#include <stdio.h>
main()
{
int n,i=1,j,c;
clrscr();
printf("Enter Number Of Terms
");
printf("Prime Numbers Are Follwing
");
scanf("%d",&n);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
printf("%d ",i)
i++;
}
getch();
}
--------------------------------------------------------------------------------------------------------------------------------------------------

2)Program for finding the prime numbers

#include <stdio.h>
#include <conio.h>
void main()
{
int n,m,k,i,max;
char c;
clrscr();
repeat: max=0;
k=2;
n=1;
printf("You want prime numbers upto:- ");
scanf("%d",&max);
printf("

");
for (i=1;i<=max;i++)
{
again: m=(n/k)*k;
if (m!=n)
k=k+1;
else
goto try1;
if (k < n/2)
goto again;
else
printf("%d",n);
printf(" ");
try1: n=n+1;
k=2;
}
fflush(stdin);
printf ("

Do you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
getch();

}
---------------------------------------------------------------------------------------------------------------------------------------------------

3)

  1. #include <stdio.h>
  2. int main(void) {
  3. int n,
  4. lcv,
  5. flag; /* flag initially is 1 and becomes 0 if we determine that n
  6. is not a prime */
  7. printf("Enter value of N > ");
  8. scanf("%d", &n);
  9. for (lcv=2, flag=1; lcv <= (n / 2); lcv++) {
  10. if ((n % lcv) == 0) {
  11. if (flag)
  12. printf("The non-trivial factors of %d are: \n", n);
  13. flag = 0;
  14. printf("\t%d\n", lcv);
  15. }
  16. }
  17. if (flag)
  18. printf("%d is prime\n", n);
  19. }
---------------------------------------------------------------------------------------------------------------------------------------------------

4)

#include<stdio.h>

#include<conio.h>

void main()

{

int n,i,c=0;

clrscr();

printf("enter the number:");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

if(n%i==0)

{

c=c+1;

}

}

if(c==2)

printf("number is prime");

else

printf("number is not prime");

getch();

}
-------------------------------------------------------------------------

5)
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the number:");
scanf("%d",&a);
for(b=2;b<a/2;b++)
{
if(n%i==0)
{
printf("\n Its not a Prime number");
c=1;
break;
}
if(flag==0)
printf("\n Its a Prime Number");
getch();
}
}


Posted on Sep 12, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

2 Answers

What is a prime number ?


A prime number is a whole number greater than one which has no divisors except one and itself. A composite number is a whole number greater than one that isn't prime, that is, a product of two or more whole numbers. See http://en.wikipedia.org/wiki/Prime_number

Jul 07, 2014 | Operating Systems

1 Answer

Http//192. 168.0. 101 :8080


NetName: PRIVATE-ADDRESS-CBLK-RFC1918-IANA-RESERVED
NetHandle: NET-192-168-0-0-1
Parent: NET192 (NET-192-0-0-0-0)
NetType: IANA Special Use
OriginAS:
Organization: Internet Assigned Numbers Authority (IANA)
RegDate: 1994-03-15
Updated: 2013-08-30
Comment: These addresses are in use by many millions of independently operated networks, which might be as small as a single computer connected to a home gateway, and are automatically configured in hundreds of millions of devices. They are only intended for use within a private context and traffic that needs to cross the Internet will need to use a different, unique address.
Comment:
Comment: These addresses can be used by anyone without any need to coordinate with IANA or an Internet registry. The traffic from these addresses does not come from ICANN or IANA. We are not the source of activity you may see on logs or in e-mail records. Please refer to http://www.iana.org/abuse/answers
Comment:
Comment: These addresses were assigned by the IETF, the organization that develops Internet protocols, in the Best Current Practice document, RFC 1918 which can be found at:
Comment: http://datatracker.ietf.org/doc/rfc1918
Ref: https://whois.arin.net/rest/net/NET-192-168-0-0-1


OrgName: Internet Assigned Numbers Authority
OrgId: IANA
Address: 12025 Waterfront Drive
Address: Suite 300
City: Los Angeles
StateProv: CA
PostalCode: 90292
Country: US
RegDate:
Updated: 2012-08-31
Ref: https://whois.arin.net/rest/org/IANA


OrgAbuseHandle: IANA-IP-ARIN
OrgAbuseName: ICANN
OrgAbusePhone: +1-310-301-5820
OrgAbuseEmail: abuse@iana.org
OrgAbuseRef: https://whois.arin.net/rest/poc/IANA-IP-ARIN

OrgTechHandle: IANA-IP-ARIN
OrgTechName: ICANN
OrgTechPhone: +1-310-301-5820
OrgTechEmail: abuse@iana.org
OrgTechRef: https://whois.arin.net/rest/poc/IANA-IP-ARIN

Dec 06, 2013 | Operating Systems

1 Answer

Find the prime number between 1 to 50


using System;

class MainClass {
public static void Main() {
int num;
int i;
int factor;
bool isprime;


for(num = 1; num < 50; num++) {
isprime = true;
factor = 0;

// see if num is evenly divisible
for(i=2; i <= num/2; i++) {
if((num % i) == 0) {
// num is evenly divisible -- not prime
isprime = false;
factor = i;
}
}

if(isprime)
Console.WriteLine(num + " is prime.");
else
Console.WriteLine("Largest factor of " + num +
" is " + factor);
}

}
}

Feb 01, 2011 | Operating Systems

1 Answer

When i try to connect my idea net setter.it gives a message that ypu can't connect before register an available network.though i am using my idea sim card in the usb net setter.actually i had by mistake...


Dear Sir,

Kindly provide your cellular number for further assistance. You can also get in touch with our Customer care centre - details updated on Idea website. www.ideacellular.com.

Regards, Idea Cellular

Nov 16, 2010 | Operating Systems

1 Answer

Generate prime nos upto n


Just do a search for Sieve of Eratosthenes to find an efficient algorithm for finding prime numbers. You can probably find source code in multiple languages for this purpose as well.

Jul 06, 2009 | Microsoft Operating Systems

1 Answer

I need a java source code file that is just like a ATM machine which saves the transactions...for example if you have withdrawn $1000 from your atm account and you have $5000 dollars...it would save the...


/* Program to Find whether number is Prime or Not. */

class PrimeNo{

public static void main(String args[]){

int num = Integer.parseInt(args[0]);

int flag=0;

for(int i=2;i<num;i++){

if(num%i==0)

{

System.out.println(num+" is not a Prime Number");

flag = 1;

break;

}

}

if(flag==0)

System.out.println(num+" is a Prime Number");

}

}

May 16, 2009 | Microsoft Windows XP Professional With...

1 Answer

Code for prime numbers in c


Prime numbers can be calculated by using recursive algorithm
int i,j=1;
i++;
for (j=2;j<i;j++)
{
If (i%j==0)printf(" %d number is prime",&i );
else printf(" %d number is not prime",&i);
i++;
delay(20);
}
Ctrl break to terminate execution or other

Jan 29, 2009 | Operating Systems

2 Answers

Vb code for automatic number change


You want the code for when you press enter in textbox it automatically change to 1.

I am typing C# code you can easly covert it to VB.Net code

make an event for key press for textbox
and write the followting code in the event
IF textbox1.text = ""
textbox1.text = "1"
End IF

I hope your problem will solve with this If need more assistance let me know. If your problem is solved then don't forget to make answer my thread.

Regards

Nov 17, 2008 | Operating Systems

Not finding what you are looking for?
Operating Systems Logo

Related Topics:

210 people viewed this question

Ask a Question

Usually answered in minutes!

Top Operating Systems Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18298 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Prashant  Sharma
Prashant Sharma

Level 3 Expert

1127 Answers

Are you an Operating System Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...