how can write all 1to 100 prime numbers using for loop,if and
break ?

Answer Posted / divyanshu

#include<iostream.h>
#incude<conio.h>
int main()
{
int x=100,i,p=1;
cout<<"enter the no.";
cin>>x;
for(i=2;i<x;i++)
{
if(x%i==0)
{
p=2;
break;
}
if(x==1)
{
cout<<"prime no.";
}
getch();
}

Is This Answer Correct ?    2 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the advantages of using macro in c language?

585


What is a program flowchart?

609


What is the difference between functions getch() and getche()?

626


Explain the meaning of keyword 'extern' in a function declaration.

733


What is data structure in c and its types?

599






Can we add pointers together?

622


What is the modulus operator?

743


What do mean by network ?

661


Why doesnt the call scanf work?

679


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2338


What will be the outcome of the following conditional statement if the value of variable s is 10?

774


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1624


How are strings stored in c?

599


What are the types of unary operators?

667


What is 'bus error'?

651