Pages

Showing posts with label prime. Show all posts
Showing posts with label prime. Show all posts

Saturday, April 12, 2014

Print prime number 1 to 100

Q. Write a C program to accept a specific last number and print all the less then or equal prime number.
or
Q. Write a C program to print the prime number between 1 to n number.
for example: 1 to 100

Ans.

Note:-
1. 1 is not the prime number.
2. All even number is not the prime number except the number 2.

/*C program to print 1 to 100 prime numbers*/
#include<stdio.h>
#include<conio.h>
int main()
{
 int num,n,div,p;
 printf("Enter any number: ");
 scanf("%d", &num);
 for(n=2; n<=num; n++)
 {
  for(div=2; div<n; div++)
  {
   if(n%div==0)
   {
     p=0;
     break;
   }
   p=1;
  }
  if(p)
    printf(" %d",n);
 }
 getch();
 return 0;
}

/************Output************/


Output of print 1 to 100 prime number C program
Screen shot for print the prime number
between 1 to 100 C program

Related program:

  1. Generate first n prime number C program
  2. Search for prime number C program
  3. Flowchart for search prime number
Read More..

Monday, March 24, 2014

Metroid Prime Preview Channel is out Blog Update

It has finally been released in the UK, the Metroid Prime Preview Channel, previously only released in America, has just been released in the UK. It is so cool and I now cant wait for this game, now only 11 days and 17 hours away! Another video will be released on the 17th. Graphically, the game looks quite similar to Metroid Prime 1, however, it is worth bearing in mind that this video is streamed over the internet and also, even if they are only mildly better than MP1, they are still very good.

Talking of Metroid Prime 1, I am nearly finished. I am on the second to last boss fight at the moment. I must admit that I did cheat slightly as I looked up the locations of the Artifacts, but I was pretty much right before, I was just not doing the right thing. However, I will have the game and the review finished by the 25th October.

On the release day of Metroid Prime 3, I will being posting a post that I will update with "Live Impressions". Every so often (5 minutes or so) I will post a sentence or a picture from the game. So, if you are interested, make sure you are here at 9:30ish GMT

My Halo 3 first impressions are nearly finished and I will release that some time today or tomorrow. I am currently doing work experience at my old school, so that is why I havent posted it before.

I have received many updates for my Wii recently, each time getting my hopes up that it will be the Metroid Preview channel. One of them allowed the Wii to support USB keyboards. I do not have a USB keyboard so was unable to test this, however it has much further reaching implications. Namely, that through the updates, support for other USB items can be released, for example a USB headset or external hard drive.
Read More..