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

Is the exit() function same as the return statement? Explain.

0 Answers   Agilent, ZS Associates,


Who invented b language?

0 Answers  


1)which of following operator can't be overloaded. a)== b)++ c)?! d)<=

16 Answers   CybOrg, Siemens,


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

0 Answers  


What is structure padding in c?

0 Answers  






How can you pass an array to a function by value?

0 Answers  


what are the 10 different models of writing an addition program in C language?

0 Answers  


How can I get the current date or time of day in a c program?

0 Answers  


How can we see the Expanded source code and compiled code for our source program in C?

1 Answers  


explain what is a newline escape sequence?

0 Answers  


write a c program for swapping two strings using pointer

0 Answers  


Explain data types & how many data types supported by c?

0 Answers  


Categories