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 swap 3 numbers without using 4th variable?

5 Answers  


What is an auto keyword in c?

0 Answers  


How can I recover the file name given an open stream?

0 Answers  


How does placing some code lines between the comment symbol help in debugging the code?

0 Answers  


what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

0 Answers  


/*what is the output for the code*/ void main() { int r; r=printf("naveen"); r=printf(); printf("%d",r); getch(); }

1 Answers   CDAC,


Can 'this' pointer by used in the constructor?

0 Answers  


difference between i++* and *++i

6 Answers   IBM,


Explain the difference between null pointer and void pointer.

0 Answers   TCS,


What is sizeof c?

0 Answers  


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

0 Answers  


Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?

6 Answers  


Categories