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...


Please write me a program to print the first 50 prime
numbers (NOT between the range 1 -50)

Answers were Sorted based on User's Feedback



Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)..

Answer / antony

#include<stdio.h>


void main()
{
int count=0;
int num=1;
int i;

printf("prime nums \n");
while(count<50)
{
num++;
for (i=2;i<=num-1;i)
{
if(num%i==0)break;
i++;
}
if(i>=num-1)
{
printf("%d ",num);
count++;
}

}
}

Is This Answer Correct ?    93 Yes 47 No

Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)..

Answer / pirya

#include<stdio.h>
#include<conio.h>
void main()
{
int count==0,n=0,i=1,j=1;
clrscr();
while(n<50)
{
j=1;
count=0;
while(j<=1)
{
if(count%i==0)
count++;
j++;
}
if(count==2)
{
printf("%d ",i);
n++;
}
i++;
}
getch();
}

Is This Answer Correct ?    13 Yes 15 No

Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)..

Answer / ankurmohansharma

#include<stdio.h>
#include<conio.h>
main()
{
int loop_counter,count_prime=1,divisor;
clrscr();
loop_counter=51; //it will exclude all less then 50
while(count_prime!=50)
{
for(divisor=2;divisor<=loop_counter-1;divisor++)
{
if (loop_counter % divisor==0)
{ break;
}
}
if(loop_counter==divisor)
{
printf("\n%d",loop_counter);
count_prime++;
}
loop_counter++;
}
getch();
}

Is This Answer Correct ?    8 Yes 19 No

Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)..

Answer / sofi

#include <stdio.h>
#include <conio.h>

main()
{
int num,count_prime=1,divisor;
//clrscr();
num =1; //it will exclude all less then 50
while(count_prime!=50)
{
for(divisor=2;divisor<=num;divisor++)
{
if (num % divisor==0)
{ break;
}
}
if(num==divisor)
{
printf("\n%d",num);
count_prime++;
}
num++;
}
getch();
}

Is This Answer Correct ?    10 Yes 21 No

Please write me a program to print the first 50 prime numbers (NOT between the range 1 -50)..

Answer / azad sable, chiplun

void main()
{
int i,n=1;
clrscr();
printf("\nprime no. between 1 to50 are:\n1\t);
while(n<=50)
{
i=2;
while(i<n)
{
if(n%1==0)
break;
else
i++;
}
if(i==n)
printf("%d\t",n);
n++;
}
getch();
}

Is This Answer Correct ?    20 Yes 34 No

Post New Answer

More C Interview Questions

Write a c program using for loop in switch case?

1 Answers   Infosys,


what type of questions arrive in interview over c programming?

0 Answers  


Define recursion in c.

0 Answers  


How do you define a function?

0 Answers  


in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?

11 Answers   IBM,


How do i store a paragraph into a string? for example, if i input a long paragraph, the program will read the words one by one and concatenate them until no word is left.

1 Answers  


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

8 Answers   Aspire,


what is diognisis?

1 Answers  


How do I swap bytes?

0 Answers  


How can I automatically locate a programs configuration files in the same directory as the executable?

0 Answers  


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

0 Answers  


Write a program to compare two strings without using the strcmp() function

42 Answers   Accenture, Arba Minch University,


Categories