Posts

write a program that takes the first term and the value n and kth term in the series

Image
#include <stdio.h> int main() {     int i,n,k=4;     printf("Enter the value of n");     scanf("%d",&n);     for(i=2;i<=n;i++)     {         if(i%2==0)         {             k=k+5;         }         else             k=k-2;     }     printf("%d",k);     return 0; } OUTPUT: Enter the value of n 5 10

Accept a positive integer and find next prime number to it

Image
#include <stdio.h> int main() {     int i,j,x;     printf("Enter The Value of X");     scanf("%d",&x);     for(i=x+1;i<=x+10;i++)     {         for(j=2;j<=i;j++)         {             if(i%j==0)             {                 break;             }         }         if(i==j)         {             printf("%d",i);             break;         }     }     OUTPUT: Enter The Value of X 8 11

series of numbers when a sequence of prime numbers are added

Image
int main() {   int i,j,k=4; for(i=2;i<=13;i++) {   for(j=2;j<=i;j++)   {     if(i%j==0)     {       break;     }   }     if(i==j)     {        k= k+i;     printf("%d ",k);     } }   return 0; } OUTPUT:

Geometric progression

Image
#include <stdio.h> int main() { long int a,r; printf("Enter a\n"); scanf("%ld",&a); printf("Enter r\n"); scanf("%ld",&r); long int k=1,n; printf("Enter n\n"); scanf("%ld",&n); if(r==3||r==4) {   if(n%2!=0)   {     n = (n/2)+1;     for(long i=1;i<n;i++)     {       k=k*r;     }     k= a*k;     printf("%d",k);   }   else   {     n = n/2;     for(long i=1;i<n;i++)     {       k=k*r;     }     k= a*k;     printf("%d",k);   } } } OUTPUT: Enter a 1 Enter r 3 Enter n 11 243

print an array in zigzag order

Image
int main() { int a[7]={3,4,6,2,1,8,9}; int flag =0,n=3,i=0,k; while(n) {     if(flag==0&&a[i]<a[i+1])     {             flag=1;       i++;     }     else{       k=a[i];       a[i]=a[i+1];       a[i+1]=k;       i++;           }     if(flag==1&&a[i]>a[i+1])     {          flag=0;         i++;     }     else     {       k=a[i];       a[i]=a[i+1];       a[i+1]=k;       i++;           }         n--; } for(i=0;i<7;i++) {   printf("%d\t",a[i]); } } OUTPUT:

Print 2-D array in spiral order

#include <stdio.h> int main() { int arr[3][3]= {                 {1, 2, 3},                 {4, 5, 6},                 {7, 8, 9},             };        spiral(arr);    return 0; } void spiral(int arr[3][3]) {     int top =0,right=2,left=0,bottom=2,dir =1, i;         while(top <= bottom && left <= right)     {         if (dir==1)         {             for( i =0;i<=2;++i)             {                 printf("%d",arr[top][i]);             }               ++top;               dir=2;   ...

HANGMAN GAME IN JAVASCRIPT

<html> <script> alert("Note: This ia a Game where You will guess words by using input as letters you shoud give input based on blankspaces && your guessing is limited to 15"); var words= ["javascript","monkey","amazing","pancake","album", "atlas", "bestseller", "booklet", "brochure", "codex", "compendium", "copy", "dictionary", "dissertation", "edition", "encyclopedia", "essay", "fiction", "folio", "handbook", "hardcover", "leaflet", "lexicon", "magazine", "manual", "monograph","nonfiction", "novel", "octavo", "offprint", "omnibus", "opus", "opuscule", "pamphlet", "paperback", ...