Friday, February 10, 2017

WAP IN C TO FIND WHETHER THE ENTERED NUMBER IS PALINDROME OR NOT

/*PROGRAM BY LAXMAN POUDEL*/

#include <stdio.h>
int main()
{
    int n, reversedInteger = 0, remainder, originalInteger;

    printf("Enter an integer: ");
    scanf("%d", &n);
    printf("*****PROGRAMMING SEEKERS BLOG*****");
    originalInteger = n;

    // reversed integer is stored in variable 
    while( n!=0 )
    {
        remainder = n%10;
        reversedInteger = reversedInteger*10 + remainder;
        n /= 10;
    }

    // palindrome if orignalInteger and reversedInteger are equal
    if (originalInteger == reversedInteger)
        printf("%d is a palindrome.", originalInteger);
    else
        printf("%d is not a palindrome.", originalInteger);
    
    return 0;
}

Friday, February 3, 2017

                ARDUINO  STEPPER MOTOR TEST PROGRAM

                                   /*PROGRAM BY LAXMAN POUDEL*/
#include <AFMotor.h>
AF_Stepper motor(200, 2);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor.setSpeed(50); // 10 rpm
motor.step(400, FORWARD, SINGLE);
motor.release();
delay(1000);
}
void loop() {
motor.step(200, FORWARD, SINGLE);
motor.step(200, BACKWARD, SINGLE);
motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);
motor.step(200, FORWARD, INTERLEAVE);
motor.step(200, BACKWARD, INTERLEAVE);
motor.step(200, FORWARD, MICROSTEP);
motor.step(200, BACKWARD, MICROSTEP);
}

                                                           COMPLIED SKETCH                                                                   

                                                                                                                                                                 

HTML CODE TO CREATE A SIMPLE CALCULATOR

                                            / *PROGRAM BY LAXMAN POUDEL/*
<html>
<head>
<title>HTML CALCULATOR</title>
<p> HTML CALCULATOR BY LAXMAN POUDEL</p>
</head>
<table border="10" width="15">
<body bgcolor= "#000000" text= "gold">
<form name="calculator" >
<tr>
<td><input type="button" value="1" onClick="document.calculator.ans.value+='1'"></td>
<td><input type="button" value="2" onClick="document.calculator.ans.value+='2'"></td>
<td><input type="button" value="3" onClick="document.calculator.ans.value+='3'"></td></tr>
 <input type  ="button" value="+"     onClick="document.calculator.ans.value+='+'">

<tr>
<td><input type="button" value="4" onClick="document.calculator.ans.value+='4'"></td>
<td><input type="button" value="5" onClick="document.calculator.ans.value+='5'"></td>
<td><input type="button" value="6" onClick="document.calculator.ans.value+='6'"></td></tr>
<input type="button" value="-" onClick="document.calculator.ans.value+='-'">

<tr>
<td><input type="button" value="7" onClick="document.calculator.ans.value+='7'">
<td><input type="button" value="8" onClick="document.calculator.ans.value+='8'"></td>
<td><input type="button" value="9" onClick="document.calculator.ans.value+='9'"></td>
<input type="button" value="*" onClick="document.calculator.ans.value+='*'"></td>
<input type="button" value="/" onClick="document.calculator.ans.value+='/'"></tr>

<input type="button" value="0" onClick="document.calculator.ans.value+='0'">
<input type="reset" value="Reset"></td>
<input type="button" value="=" onClick="document.calculator.ans.value=eval(document.calculator.ans.value)">
<br>Calculation Is <input type="textfield" name="ans" value=""></tr>

</form>
</table>
</body>    
</html>                                            OUTPUT WINDOW     



WATCH FULL TUTORIAL TO KNOW HOW TO CREATE HTML CALCULATOR

WAP TO FIND ENTERED NUMBER IS PRIME NUMBER OR NOT


/ * C program to find the Number is Prime or not-Prime */ 
           /*Program By Laxman Poudel*/
#include<stdio.h>
main()
{
 int n,r=1,d=2;
 printf("\n Enter the Number : ");
 scanf("%d",&n);
 if(n==2)
 {
   printf("\n %d is a Prime Number \n",n);
   exit(0); //to exit from program
 }
 r=n%d; /*we have to do this before while also becuuse
 if while condition fails then r=n%d inside while is not executed*/

 while(d<=n/2)
 {
  r=n%d;
  if(r==0)
  break; //if r==0, then to come out of while loop
  d++; //incrementing d value if(r==0) fails..
}
if(r==0||n==1) // since 1 is not a prime number
printf("\n %d is not a Prime Number \n",n);
else
printf("\n %d is a Prime Number \n",n);
return(0);

}                           OUTPUT OF THE PROGRAM


C PROGRAM TO PRINT NUMBERS 1 TO N WITHOUT USING LOOPS

/*PROGRAM BY LAXMAN POUDEL*/
WAP program in c to print all numbers from 1 to N numbers using looping.
#include<stdio.h>
void print_numbers(int,int); //declaring function definition
main()
{
  int n;
  printf("\n *** PROGRAMMING SEEKERS BLOG ***");
  printf("\n >>> Program to print numbers 1 to n without using Loops <<<");
  printf("\n\n Enter the value of n: ");
  scanf("%d",&n); //taking value of n as input from user
  print_numbers(1,n); //calling the function
  getch();
}
void print_numbers(int i,int max)
{
 printf("%3d\t",i);
   if(i<max)
   {
    //calling function recursively
    print_numbers(++i,max);
   }
   return;
}
OUTPUT OF THE PORGRAM

C PROGRAM TO FIND LARGEST AND SMALLEST NUMBER IN AN ARRAY

/*PROGRAM BY LAXMAN POUDEL*/ WAP in c to find the largest and smallest numbers using array

#include<stdio.h>
#define MAX 25 //maximum size of array is 25

main()
{
  int i,n,LargeNo,SmallNo,arr[MAX];

  printf(" ***PROGRAMMING SEEKERS BLOG  ***");
  printf("\n >>> Program to find Largest element in array <<<");
  printf("\n\n Enter the size of array: ");
  scanf("%d",&n); //taking size of array as input from user
  printf("\n Enter the %d elements of array: \n",n);
  
  //taking input all the elements of array using for loop
  for(i=0;i<n;i++)
  {
   printf("\n arr[%d]:",i+1);
   scanf("%d",&arr[i]);    
  }
   LargeNo = arr[0];
   SmallNo = arr[0];
   for(i=0;i<n;i++)
   {
    //checking for Largest Number
    if(arr[i]>LargeNo)
    {
     LargeNo = arr[i];
    }
    //checking for Smallest Number
    if(arr[i]<SmallNo)
    {
     SmallNo = arr[i];
    }
   }
  //printing the largest and Smallst elements in array
  printf("\n The Largest Element in the Array is: %d ",LargeNo);
  printf("\n The Smallest Element in the Array is: %d ",SmallNo);
  getch();
}

                              OUTPUT OF THE PROGRAM
 

            C PROGRAM TO  CALCULATE  FACTORIAL OF A NUMBER USING RECURSION              

WAP in c  to calculate the factorial of a number. Use the concept of recursion 
instead of using loops.


#include<stdio.h>
main()
{
int afact;
printf("\nEnter any number: ");
scanf ("%d"&a);
fact=rec (a);
printf("\nFactorial Value = %d"fact);
getch();
}
rec (int x)
{
int f;
if (x==1)
return (1);
else
f=x*rec(x-1);
return (f);                                           OUTPUT OF THE PROGRAM
}