embedded system,arduino,raspberry pi,msp430f169, ARM7

Friday, May 31, 2019

On 5:12 AM by EDUCATION in    No comments
/* ***********************************************
    Write a program to print  decimal numbers to hexa decimal format in arrays

 date:31-05-2019
 created by:ANIL DURGAM

*****************************************************/


#include <stdio.h>
#include <stdlib.h>

int main()
{

    int i;
    char ch[30]={120,120,31,18,01,8,69,86,70,33,30,80,42,00,01,140,221,13,10};
    char str[50];
    char str2[50];

    strcpy(str2,"");
    for(i=0;i<20;i++)
    {
         strcpy(str,"");
         sprintf(str,"%x",ch[i]);
         strcat(str2,str);
    }
    printf("%s",str2);

    return 0;
}

On 1:21 AM by EDUCATION   No comments
/* ***********************************************
    Write a program to print reverse of the given numbers

 date:31-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{   int a=0,b=0;
    printf("please enter a number\n");
    scanf("%d",&a);
    b=a%10;
    printf("%d",b);
    b=a/10;
    a=b%10;
    printf("%d",a);
    a=b/10;
    printf("%d\n",a);
    return 0;
}

Thursday, May 30, 2019

On 5:37 AM by EDUCATION   No comments

/* ***********************************************
    Write a program to print prime numbers below 100

 date:30-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

void prime_fn(int num);

void main()
{
   int n;

  // printf("Enter a number to check if it is prime\n");
  // scanf("%d",&n);
  for(n=2;n<100;n++)
  {
       prime_fn(n);
  }

   return 0;
}

void prime_fn(int num)
{
    int c;
     for ( c = 2 ; c <= num - 1 ; c++ )
   {
      if ( num%c == 0 )
      {
         //printf("%d isn't prime.\n", num);
     break;
      }
   }
   if ( c == num )
      printf("%d is prime.\n", num);
}

On 5:29 AM by EDUCATION   No comments

/* ***********************************************
    Write a program to find prime number or not using functions

 date:30/-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

void prime_fn(int num);

void main()
{
   int n;

   printf("Enter a number to check if it is prime\n");
   scanf("%d",&n);
    prime_fn(n);
   return 0;
}

void prime_fn(int num)
{
    int c;
     for ( c = 2 ; c <= num - 1 ; c++ )
   {
      if ( num%c == 0 )
      {
         printf("%d isn't prime.\n", num);
     break;
      }
   }
   if ( c == num )
      printf("%d is prime.\n", num);
}

On 5:19 AM by EDUCATION   No comments

/* ***********************************************
    Write a program to find prime number or not

 date:30-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

main()
{
   int n, c = 2;

   printf("Enter a number to check if it is prime\n");
   scanf("%d",&n);

   for ( c = 2 ; c <= n - 1 ; c++ )
   {
      if ( n%c == 0 )
      {
         printf("%d isn't prime.\n", n);
     break;
      }
   }
   if ( c == n )
      printf("%d is prime.\n", n);

   return 0;
}


On 3:48 AM by EDUCATION   No comments
#include <windows.h>
#include <gl/gl.h>

LRESULT CALLBACK WindowProc(HWND, UINT, WPARAM, LPARAM);
void EnableOpenGL(HWND hwnd, HDC*, HGLRC*);
void DisableOpenGL(HWND, HDC, HGLRC);


int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    WNDCLASSEX wcex;
    HWND hwnd;
    HDC hDC;
    HGLRC hRC;
    MSG msg;
    BOOL bQuit = FALSE;
    float theta = 0.0f;

    /* register window class */
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_OWNDC;
    wcex.lpfnWndProc = WindowProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = "GLSample";
    wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);;


    if (!RegisterClassEx(&wcex))
        return 0;

    /* create main window */
    hwnd = CreateWindowEx(0,
                          "GLSample",
                          "OpenGL Sample",
                          WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          256,
                          256,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);

    ShowWindow(hwnd, nCmdShow);

    /* enable OpenGL for the window */
    EnableOpenGL(hwnd, &hDC, &hRC);

    /* program main loop */
    while (!bQuit)
    {
        /* check for messages */
        if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            /* handle or dispatch messages */
            if (msg.message == WM_QUIT)
            {
                bQuit = TRUE;
            }
            else
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
        else
        {
            /* OpenGL animation code goes here */

            glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            glPushMatrix();
            glRotatef(theta, 0.0f, 0.0f, 1.0f);

            glBegin(GL_TRIANGLES);

                glColor3f(1.0f, 0.0f, 0.0f);   glVertex2f(0.0f,   1.0f);
                glColor3f(0.0f, 1.0f, 0.0f);   glVertex2f(0.87f,  -0.5f);
                glColor3f(0.0f, 0.0f, 1.0f);   glVertex2f(-0.87f, -0.5f);

            glEnd();

            glPopMatrix();

            SwapBuffers(hDC);

            theta += 1.0f;
            Sleep (1);
        }
    }

    /* shutdown OpenGL */
    DisableOpenGL(hwnd, hDC, hRC);

    /* destroy the window explicitly */
    DestroyWindow(hwnd);

    return msg.wParam;
}

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
        case WM_CLOSE:
            PostQuitMessage(0);
        break;

        case WM_DESTROY:
            return 0;

        case WM_KEYDOWN:
        {
            switch (wParam)
            {
                case VK_ESCAPE:
                    PostQuitMessage(0);
                break;
            }
        }
        break;

        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }

    return 0;
}

void EnableOpenGL(HWND hwnd, HDC* hDC, HGLRC* hRC)
{
    PIXELFORMATDESCRIPTOR pfd;

    int iFormat;

    /* get the device context (DC) */
    *hDC = GetDC(hwnd);

    /* set the pixel format for the DC */
    ZeroMemory(&pfd, sizeof(pfd));

    pfd.nSize = sizeof(pfd);
    pfd.nVersion = 1;
    pfd.dwFlags = PFD_DRAW_TO_WINDOW |
                  PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;

    iFormat = ChoosePixelFormat(*hDC, &pfd);

    SetPixelFormat(*hDC, iFormat, &pfd);

    /* create and enable the render context (RC) */
    *hRC = wglCreateContext(*hDC);

    wglMakeCurrent(*hDC, *hRC);
}

void DisableOpenGL (HWND hwnd, HDC hDC, HGLRC hRC)
{
    wglMakeCurrent(NULL, NULL);
    wglDeleteContext(hRC);
    ReleaseDC(hwnd, hDC);
}

On 3:12 AM by EDUCATION   No comments
/*************************************************
    Write a Program to find the LCM and HCF of two numbers

 date:30/-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int x,y,a,b;
     printf("Enter two numbers");
     scanf("%d %d",&x,&y);
      a=x;
      b=y;
      while(a!=b)
        {
            if(a<b)
                a=a+x;
            else
                b=b+y;
        }
        printf("LCM of %d and %d is %d\n",x,y,a);
         a=x; b=y;
         while(a!=b)
            {
                if(a>b)
                    a=a-b;
                else
                    b=b-a;
                }
                printf("HCF of %d and %d is. %d\n", x, y, a) ;

    return 0;
}

On 2:45 AM by EDUCATION   No comments
/*************************************************
    Write a program to find triad numbers..
1.Each number is a three digit number.
2.All the digits in the three numbers (total 9 digits) should be different.
3.Second number should be twice the first number and third number should be thrice the first number.
  For example
  219 438 657
  267 534 801

 date:30/-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

int main()
{
   int m,n,p,num;
   int i,k,dl,d2,d3;
    for(num=100;num<=999/3;num++)/*Loop A*/
        {
            for (i=num; i<=3 *num; i+=num) /* loop B */
             {
                 k=i;
                 dl=k%10;
                 k/=10;
                 d2=k%10;
                 k/=10;
                 d3=k%10;
                 k/=10;
                 if(dl==d2 || d2==d3 || d3==dl)
                    goto nextnum;
            } /*Endof loop B*/

            for(m=num;m>0;m/=10) /*Loop c*/
                {
                    dl=m%10;
                    for(n=num*2;n>0;n/=10) /*Loop D*/
                    {
                        d2=n%10;
                        for(p=num*3;p>0;p/=10) /*Loop E*/
                        {
                            d3=p%10;
                            if(dl==d2 || d2==d3 || dl==d3)
                                goto nextnum;
                        } /*End of Loop E*/
                    } /*End of Loop D*/
                }/*End of loop C*/
                 nextnum:
                            printf("%d\t%d\t%d\n",num,num*2,num*3);

        } /*End of loop A*/

    //return 0;
}

On 2:04 AM by EDUCATION   No comments
/* ***********************************************
    Write a program to find date of birth.......day....


 date:30/-05-2019
 created by:ANIL DURGAM

*****************************************************/

#include <stdio.h>
#include <stdlib.h>

#include<stdio.h>
#include<stdlib.h>

int main() {
 int d, m, y, year, month, day, i;

 printf("Enter date of birth (DD MM YYYY) :");
 scanf("%d %d %d", &d, &m, &y);
 if( (d > 31) || (m > 12) || (y < 1900 || y >= 2100) )
 {
    printf("INVALID INPUT. Please enter a valid date between 1900 and 2100");
    exit(0);
 }

    year = y-1900;
    year = year/4;
    year = year+y-1900;

    switch(m)
        {
            case 1:
            case 10:
            month = 1;
            break;
             case 2:
             case 3:
             case 11:
             month = 4;
             break;
             case 7:
             case 4:
             month = 0;
             break;
             case 5:
             month = 2;
             break;
             case 6:
             month = 5;
             break;
             case 8:
             month = 3;
             break;
             case 9:
             case 12:
             month = 6;
             break;
 }

         year = year + month;
         year = year + d;
         /* Need to make sure extra day is not needed in leap year for dates before March */
         if(( y > 1900 ) && ( y % 4 == 0 ) && ( m < 2 ) )
         year--;
         day = year % 7;

         switch(day)
         {
             case 0:
             printf("Day is SATURDAY\n");
             break;
             case 1:
             printf("Day is SUNDAY\n");
             break;
             case 2:
             printf("Day is MONDAY\n");
             break;
             case 3:
             printf("Day is TUESDAY\n");
             break;
             case 4:
             printf("Day is WEDNESDAY\n");
             break;
             case 5:
             printf("Day is THURSDAY\n");
             break;
             case 6:
             printf("Day is FRIDAY\n");
             break;
         }

 return 0;
}

On 12:18 AM by EDUCATION   No comments
/* this is the program to find
    given alphabet is vowel or consonant using switch


 date:30/-05-2019
 created by:ANIL DURGAM

*/

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char i;
    printf("please enter your choice\n");
    scanf("%c",&i);
    switch(i)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            printf("you have entered vowel\n");
            break;

        default:
            printf("you have entered consonant\n");
    }
    return 0;
}



Saturday, May 25, 2019

On 3:14 AM by EDUCATION   No comments
//program 1

#include <stdio.h>
int main()
{
int arr[]={0x78, 0x78};
int i;

printf("Array elements are\n");
for(i=0;i<2;i++)
printf("Hex: %X\n",arr[i]);

return 0;
}


//program 2

#include <stdio.h>
int main()
{
unsigned char a=0x64;
int b=0xFA;

printf("value of a: %X [%x]\n",a,a);
printf("value of b: %X [%x]\n",b,b);

return 0;
}

On 2:18 AM by EDUCATION   No comments
//a program to print large number using conditional operator
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int a,b,max;
   printf("enter values for a and b");
   scanf("%d %d",&a,&b);
   max = a>b ? a:b;
   printf("entered values are%d,%d,%d",a,b,max);
       return 0;
}
On 2:17 AM by EDUCATION   No comments
//getchar and putchar test


#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;
    printf("enter a character\n");
    ch = getchar();
    printf("entered character is ");
    putchar(ch);
    return 0;
}

Friday, May 3, 2019

On 8:48 PM by EDUCATION   No comments
Recently we started hearing the word ...most famous words like data science and machine learning and neural networks.

First of all we need to know the  little basics about python and its programming styles then we can learn step by step how   how deep it is.