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 are the 5 data types?

0 Answers  


How would you rename a function in C?

0 Answers   Tech Mahindra,


What is scanf_s in c?

0 Answers  


How would you write qsort?

1 Answers  


10. Study the code: void show() main() { show(); } void show (char *s) { printf("%sn",s); } What will happen if it is compiled & run on an ANSI C Compiler? A)It will compile & nothing will be printed when it is executed B)it will compile but not link C)the compiler will generate an error D)the compiler will generate a warning

5 Answers   Accenture,






What is realloc in c?

0 Answers  


Write a C program linear.c that creates a sequence of processes with a given length. By sequence it is meant that each created process has exactly one child. Let's look at some example outputs for the program. Here the entire process sequence consists of process 18181: Sara@dell:~/OSSS$ ./linear 1 Creating process sequence of length 1. 18181 begins the sequence. An example for a sequence of length three: Sara@dell:~/OSSS$ ./linear 3 Creating process sequence of length 3. 18233 begins the sequence. 18234 is child of 18233 18235 is child of 18234 ........ this is coad .... BUt i could not compleate it .....:( #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[]) { int N; pid_t pid; int cont; if (argc != 2) { printf("Wrong number of command-line parameters!\n"); return 1; } N = atoi(argv[1]); printf("Creating process sequence of length %d.\n",N); printf("%d begins the sequence.\n",getpid()); /* What I have to do next ?????? */ }

0 Answers  


console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

0 Answers  


please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }

3 Answers  


What is difference between structure and union?

0 Answers  


Explain how do you list files in a directory?

0 Answers  


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

0 Answers  


Categories