ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
      {
        int flag,x;
        clrscr();
        printf("1\t");
        for(int i=1;i<=100;i++)
          {
            flag=0;
            for(x=2;x<=i;x++)
              {
                if(i%x==0)
                  {
                    flag=1;
                    break;
                  }
                else
                  continue;
              }
            if(i==x)
            printf("%d\t",i);
          }
        getch();
      }
 
Is This Answer Correct ?    28 Yes 7 No
Abhay
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 2
#include<iostream.h>
void main()
{
int n,a;
cout<<"enter the limit";
cin>>n;
for(i=1;i<=n;i++}
{
if(i=1)
{
cout<<"1 is neither a prime nor a composite no";
}
else if(i%1==0|i%i==0)
{
cout<<i<<"is a prime number";
}
}
}
 
Is This Answer Correct ?    8 Yes 9 No
Sathya
 
 
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 3
def shaf(n):
    l=range(3,n+1,2)
    mi=n
    i=0
    r=0
    print l   
    while l[i]<n-1:
        
        for j in range(2,l[i]):
            if l[i]%j==0:
                r=5
        if r==0:
            print l[i]
            
       
        r=0
        i=i+1
       
        
if __name__ == "__main__":
    print "prime numbers from 2 to <101 "      
    shaf(100)
 
Is This Answer Correct ?    4 Yes 4 No
Shabeer V C
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 4
void main()
{
int i,j,m;
for(i=1;i<=100;i++
{
m=0
for(j=1;j<i;j++)
{
if(i%j==0)
m++;
}
if(m==0)
printf("%d",i);
getch();
}
 
Is This Answer Correct ?    7 Yes 13 No
Karthik
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 5
#include<Stdio.h>
#include<conio.h>

int main()
{
	int i,j, flag = 0;

	for(i=2;i<=100;i++)
	{
		for(j=2;j<i;j++)
		{
			if(i != j)
			{
			  if(i%j != 0)
				   continue;
			  else
				  break;
			}
		}
       if(i == j)
		printf("%d ",i);

	}
}
 
Is This Answer Correct ?    11 Yes 5 No
Santhi Perumal
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 6
#include<stdio.h>
#include<conio.h>
void main()
{
int m,flag;
printf("enter the numbers upto which you wannt to find the prime numbers :");
scanf("%d",&m);
for(int i=1;i<=m;i++)
{ 
flag=1;
  for(int j=2;j<=i/2;j++)
    {
      if(i%j==0)
       flag=0;
}
if(flag==1)
printf("\n%d",i);
}
getch();
}       


thank u
 
Is This Answer Correct ?    6 Yes 4 No
Vignesh1988i
 
  Re: write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)
Answer
# 7
#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 ?    5 Yes 3 No
Pravin
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
What is a far pointer?What is the utility?  2
what is the diff between the printf and sprintf functions?? and what is the syntax for this two functions ??  4
what does exit() do? Cadence3
i want explaination about the program and its stack reprasetaion fibbo(int n) { if(n==1 or n==0) return n; else return fibbo(n-1)+fibbo(n-2); } main() { fibbo(6); }  2
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } } ME5
what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these IBM2
what is the difference between NULL & NUL keywords in C?  3
Write a programme to find even numbers without using any conditional statement? Infosys3
how to make c program without a libary? e.g.#include<stdio.h> libary is not in c progaram.  1
design and implement a program that reads floating-points numbers in a sentinel-controlled loop until the user terminates the program by entering zero.your program should determinate and print the smallest,largest and average of the supplied numbers.  1
differentiate between const char *a; char *const a; and char const *a; HCL1
What will be result of the following program? void myalloc(char *x, int n) { x= (char *)malloc(n*sizeof(char)); memset(x,\0,n*sizeof(char)); } main() { char *g="String"; myalloc(g,20); strcpy(g,"Oldstring"); printf("The string is %s",g); } a) The string is : String b) Run time error/Core dump c) The string is : Oldstring d) Syntax error during compilation e) None of these IBM3
User define function contain thier own address or not.  2
Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press 'g' it shows the answer 7.. any can help me  4
How can I make a program in c to print 'Hello' without using semicolon in the code? C-DAC5
Which of the following are valid "include" formats? A)#include and #include[file.h] B)#include (file.h) and #include C)#include [file.h] and #include "file.h" D)#include <file.h> and #include "file.h" Accenture14
Write a program in c to input a 5 digit number and print it in words.  1
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } what will happen if you executed this code? Ramco4
What's a "sequence point"?  2
What is the diffrent between while and do while statement ?  5
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com