write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)

Answers were Sorted based on User's Feedback



write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / abhay

#include<stdio.h>
#include<conio.h>
void main()
{
int flag,x;
clrscr();
printf("1\t");
for(int i=1;i<=100;i++)
{
flag=0;
for(x=2;x<=i;x++)
{
if(i%x==0)
{
flag=1;
break;
}
else
continue;
}
if(i==x)
printf("%d\t",i);
}
getch();
}

Is This Answer Correct ?    291 Yes 108 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
int m,flag;
printf("enter the numbers upto which you wannt to find the prime numbers :");
scanf("%d",&m);
for(int i=1;i<=m;i++)
{
flag=1;
for(int j=2;j<=i/2;j++)
{
if(i%j==0)
flag=0;
}
if(flag==1)
printf("\n%d",i);
}
getch();
}


thank u

Is This Answer Correct ?    49 Yes 24 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / nachiyappan

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,c,n=1;
clrscr();
for(i=1;i<=100;i++)
{
n=n+1;
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c=c+1;
}
if(c==2)
printf("no. %d is prime",n);
else
printf("no. %d is not prime",n);
}
getch();
}

Is This Answer Correct ?    33 Yes 11 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / nachiyappan

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,c,n=1;
clrscr();
printf(" no. 1 is neither a prime nor composite no.");
for(i=1;i<100;i++)
{
n=n+1;
c=0;
for(j=1;j<=n;j++)
{
if(n%j==0)
c=c+1;
}
if(c==2)
printf("\n no. %d is prime",n);
else
printf("\n no. %d is not prime",n);
}
getch();
}

Is This Answer Correct ?    26 Yes 8 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / santhi perumal

#include<Stdio.h>
#include<conio.h>

int main()
{
int i,j, flag = 0;

for(i=2;i<=100;i++)
{
for(j=2;j<i;j++)
{
if(i != j)
{
if(i%j != 0)
continue;
else
break;
}
}
if(i == j)
printf("%d ",i);

}
}

Is This Answer Correct ?    52 Yes 38 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / pravin

#include<iostream>
using namespace std;
int main()
{
int num,i,j,flag;
cout<<"enter the no. up2 which u want prime no's:";
cin>>num;
for(i=2;i<=num;i++)
{
flag=1;
for(j-2;j<i/2;i++)
{
if(i%j==0)
flag=0;
}
if(flag==1)
cout<<i<<" ";
}
}

Is This Answer Correct ?    34 Yes 22 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / veda

pls explain me the logic of the code of printing n prime
numbers........

Is This Answer Correct ?    25 Yes 20 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / prasad avunoori

int s=0;
int c,k;
for (int i = 2; i < 100; i++)

{
c = 0;
for (int j = 1; j <= i; j++)

{
if(i%j==0)
{
c = c + 1;

}

}
if (c == 2)
{

printf("%d\n",i);
s++;

}


} printf("There are %d " ,s);

Is This Answer Correct ?    7 Yes 2 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / ali

#include<iostream.h>
#include<conio.h>


int main ()
{
for (int i=2; i<100; i++)
for (int j=2; j<i; j++)
{
if (i % j == 0)
break;
else if (i == j+1)
cout << i << "\t";

}
getch();
}

Is This Answer Correct ?    5 Yes 2 No

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)..

Answer / faizan n

/*A program to print all primes b\w 1-100*/
#include<stdio.h>
#include<conio.h>

void main()
{
int count,i=1;
int a;
int col=0;
clrscr();

for(i=1; i<101; i++)
{
count=0;
a=1;

while(a<=i)
{
if(i%a==0)
count++;
a++;
}

if(count==2)
{
printf("%d\t",i);
col++;
if(col%10==0)
printf("\n");
}

}
getch();
}

Is This Answer Correct ?    7 Yes 5 No

Post New Answer

More C Interview Questions

what is the output for this question: main() { int i=1; printf("%d%d%d",i,i++,++i); }

9 Answers  


What is #include conio h?

0 Answers  


Can we access the array using a pointer in c language?

0 Answers  


write a program structure to find average of given number

1 Answers  


program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.

3 Answers  


Why is c so powerful?

0 Answers  


When should I declare a function?

0 Answers  


How can I invoke another program from within a C program?

8 Answers  


What is the difference between malloc() and calloc()?

3 Answers  


a character variable can at a time store a) 1 character b) 8 characters c) 254 characters d) none of the above

3 Answers  


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

0 Answers   Oracle,


Explain the concept of "dangling pointers" in C.

2 Answers  


Categories