Print prime numbers between 1-300 using break and continue in c



Print prime numbers between 1-300 using break and continue in c
#include
<math.h>
#include <stdio.h>
main(){
  int i, j;
  i = 2;
  while ( i < 300 ){
     j = 2;
     while ( j < sqrt(i) ){
         if ( i % j == 0 )
            break;
         else{
            ++j;
            continue;
         }
      }
      if ( j > sqrt(i) )
            printf("%d\t", i);
      ++i;
  }
  return 0;
}

Pallindorem string

#include<string.h>
#include<stdio.h>
int main(){
  char *str,*rev;
  int i,j;
  printf("\nEnter a string:");
  scanf("%s",str);
  for(i=strlen(str)-1,j=0;i>=0;i--,j++)
      rev[j]=str[i];
      rev[j]='\0';
  if(strcmp(rev,str))
      printf("\nThe string is not a palindrome");
  else
      printf("\nThe string is a palindrome");
  return 0;
}
Pallindorem string -2 

  #include <stdio.h>

  #include <string.h>
  
  int main()
  {
     char text[100];
     int begin, middle, end, length = 0;
  
    gets(text);
 
     while ( text[length] != '\0' )
        length++;
  
     end = length - 1;
     middle = length/2;
  
     for( begin = 0 ; begin < middle ; begin++ )
     {
        if ( text[begin] != text[end] )
        {
           printf("Not a palindrome.\n");
           break;
        }
        end--;
     }
     if( begin == middle )
        printf("Palindrome.\n");
 
     return 0;
  }
 


Share on Google Plus

About Unknown

Hello, My name is Mou, I am from Dhaka, Bangladesh and who is trying keep her hand at blogging. I enjoy writing, anything from how to- pieces to endure to just anything at all. My blog will go into detail about all of article. Long time I work with adsense and blogging about 10 years. Doing some SEO work and like that. Please stay close for track down your article for your task and assignment. Feel free to contact with me at moujuena.mou@gmail.com if need. Thanks for visiting.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment