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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the c in ctime mean?

571


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

1889


Can you please compare array with pointer?

618


Do you have any idea how to compare array with pointer in c?

605


Is javascript written in c?

585






Is there any data type in c with variable size?

634


What is the difference between ++a and a++?

698


What is array within structure?

588


How can I ensure that integer arithmetic doesnt overflow?

609


Why do we use null pointer?

608


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1077


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

675


Do array subscripts always start with zero?

787


Why is c known as a mother language?

750


write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.

14965