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

Answers were Sorted based on User's Feedback



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

Answer / sandeep

#include<stdio.h>
main()
{
int a=2;

work:
printf("%d",a);
a=a+2;
check:
if(a<=100)
goto work;

}

Is This Answer Correct ?    1 Yes 0 No

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

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

More C Interview Questions

how to find sum of 5 digits in C?

4 Answers  


if a five digit number is input through the keyboard, write a program to calculate the sum of its digits. (hint:-use the modulus operator.'%')

23 Answers  


How to throw some light on the b tree?

0 Answers  


Do pointers need to be initialized?

0 Answers  


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

6 Answers   Microsoft,






Place the #include statement must be written in the program?

0 Answers  


Under what circumstances does a name clash occur?

0 Answers   InterGraph,


What is the basic structure of c?

0 Answers  


what are bit fields in c?

0 Answers  


What are header files? What are their uses?

0 Answers  


Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE;

5 Answers   Accenture, TCS,


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

0 Answers   Subex,


Categories