Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write the program for prime numbers?

Answers were Sorted based on User's Feedback



write the program for prime numbers?..

Answer / nischal

plz write the pl/sql program for prime numbers? in simple way
dat can be understood easily....

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / lavanya

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
public static void prime(int number)
{
for (int i = 1; i <= number; i++)
{
for (int j = 2; j <= number; j++)
{
if (i % j == 0)
{
if(i==j)
Console.WriteLine(i.ToString());
break;
}
}
}
}
static void Main(string[] args)
{
Console.WriteLine("Enter a number");
int number = Convert.ToInt32(Console.ReadLine());
prime(number);
Console.ReadLine();
}
}
}

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / karthika

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i=2;
clrscr();
printf("\n entert a number");
scanf("%d",&num);
while(c<=num-1)
{
if(num%i==0)
{
printf("given number is not a prime number\n");
break;
}
i++;
}
if(i==num);
printf(given number is a prime number\n");
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / varun raj s p

#include<stdio.h>

int main()
{
int n, i = 3, count, c;

printf("Enter the number of prime numbers required\n");
scanf("%d",&n);

if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
printf("2\n");
}

for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}

return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / noble

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter any number:");
scanf("%d",&a);
for(b=2;b<=a-1;b++)
{
if(a%b==0)
break;
}
if(a==b)
{
printf("%d is prime number",a);
}
else
{
printf("%d is not prime number",a);
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / anesh kumar

# include <iostream.h>
# include <conio.h>
int main()
{
int i,j=2,num=0;
cout<<"\n Enter the number";
cin>>i%j>>i;
while(j<=i/2)
{
if(i%j==0)
{
Cout<<"%d Is not prime number"<<i;
ch=1;
break;
}
else
{
j++;
}
}
if(num==0)
{
Cout<<"%d Is prime number"<<i;
}
getch();
return 0;

}

Is This Answer Correct ?    0 Yes 0 No

write the program for prime numbers?..

Answer / sudesh kumar

#include<iostream.h>
#include<conio.h>
void main()
{
int no,i,r,p=1;
cout<<"enter a no";
cin>>no;
for(i=2;i<no;i++)
{
if(r==no%i)
{
p=0;
break;
}
}
if(p==0)
{
cout<<"the prime no";
}
else
{
cout<<"the no is note prime";
}
getch();
}

Is This Answer Correct ?    13 Yes 14 No

write the program for prime numbers?..

Answer / ashok

void main()
{
int i,n;
clrscr();
printf("\nEnter the range:");
scanf("%d",&n)
printf("Prime numbers are:");
for(i=1;i<=n;i++)
{
if(i==2 || i==3 || i==5 || i==7)
printf("%d ",i);
if(i%2!=0 && i%3!=0 && i%5!=0 && i%7!=0)
printf("%d ",i);
}
getch();
}

Is This Answer Correct ?    7 Yes 8 No

write the program for prime numbers?..

Answer / oza priyanka

#include<stdio.h>
void main()
{
int num,i,cnt;
clrscr();
printf("\n\nEnter the number = ");
scanf("%d",&num);
for(i=2,cnt=0;i<num;i++)
{
if(num%i==0)
cnt=1;
}
if(cnt==0)
printf("\n\nprime number");
else
printf("\n\n not a prime number");
getch();
}

Is This Answer Correct ?    0 Yes 1 No

write the program for prime numbers?..

Answer / naseer

main(){
int no,i,count=0;
printf("enter any no");
scanf("%d",&no);
//the main logic is here
for(i=2;i<no;i++){

if(no%2==0){
count++;
}
}
if(count>=1)// if the no is less than
//5 then it shows prime
{
printf("not Prime");
}

else
printf("prime");

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

Write a program that receives as input a number omaadel-n-print, four digits.

0 Answers  


What is the purpose of the code, and is there any problem with it? unsigned int f( unsigned n ) { return –n & 7; }

1 Answers   Google,


show how link list can be used to repersent the following polynomial i) 5x+2

0 Answers   CBSE,


What extern c means?

0 Answers  


What is c language used for?

0 Answers  


Who is the founder of c language?

0 Answers  


Explain what are the advantages and disadvantages of a heap?

0 Answers  


Why functions are used in c?

0 Answers  


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

0 Answers  


What is const and volatile in c?

0 Answers  


What are nested functions in c?

0 Answers  


Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record

0 Answers   Wipro,


Categories