Tuesday 21 May 2013

C PROGRAM FOR INDIAN NATIONAL ANTHEM 'JANA GANA MANA'

The following code is in C and it produces music of Indian National Anthem based on corresponding frequencies. It just uses some of the basic functions like sound(), delay(), and nosound().



/*****************************************************************************/
#include<dos.h>
#include<stdio.h>
int main()
{
float music[]={
2484.375, 2703.125, 2921.875,
2921.875, 2921.875, 2921.875,
2921.875, 2921.875, 2921.875,
2921.875, 2921.875, 2703.125,
2921.875, 3031.25,2921.875,
2921.875, 2921.875, 2703.125,
2703.125, 2703.125, 2375,
2703.125, 2484.375
};

int delay_1[]= {
350, 350, 350, 350, 350, 350, 350,
350, 550, 350, 350, 350, 350, 350,
500, 350, 350, 500, 350, 350, 350,
350, 350

};

int delay_2[]= {
30, 70, 30, 70, 30, 70, 30, 70, 200,
30, 70, 30, 30, 250, 40, 30, 70, 70,
30, 70, 30, 30, 30
};

int i;

for(i=0;i<23;i++)
{
  sound(music[i]);
  delay(delay_1[i]);
  nosound();
  delay(delay_2[i]);
}
nosound();
return 1;
}
/******************************************************************************/
Hope you will enjoy listening National Anthem with this C program. 

2 comments: