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

Answer Posted / sureshbobra

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

Is This Answer Correct ?    2 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does #define work?

652


What is this infamous null pointer, anyway?

613


What is the difference between printf and scanf in c?

757


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

627


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

576






What is the purpose of the following code? Is there any problem with the code? void send(int count, short *to, short *from) { /* count > 0 assumed */ register n = (count + 7) / 8; switch (count % 8) { case 0: do { *to = *from++; case 7: *to = *from++; case 6: *to = *from++; case 5: *to = *from++; case 4: *to = *from++; case 3: *to = *from++; case 2: *to = *from++; case 1: *to = *from++; } while (--n > 0); } }

1962


What is external variable in c?

617


What is the use of bitwise operator?

694


What are the difference between a free-standing and a hosted environment?

747


Differentiate between #include<...> and #include '...'

620


When should you use a type cast?

595


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

616


Where local variables are stored in c?

558


State the difference between x3 and x[3].

655


What are the general description for loop statement and available loop types in c?

689