Showing posts with label Programms. Show all posts
Showing posts with label Programms. Show all posts

Simple Sound Program In C Language



In this post, You can create simple sound programm in C language.

Here, i am using only three function of "dos.h" header.

  • sound() function
  • delay() function
  • nosound() function
1. sound() function
  • sound() function turns the computer speaker on at the specified frequency.
2. delay() function
  • delay() function spends the execution for interval (miliseconds).
 3. nonsound() function 
  • nonsound function turns the computer.

Let's see the simple program of sound() function, delay() function, nosound() function.

#include<dos.h>

void main()
{
        int i;
        while(i==2000)
        {
               sound(i);
               delay(1000);
               i+100;
        }
      nosound();
}

Shutdown computer and laptop by Turbo C


Code for WindowXP
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>

void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')
{
system("C:\\WINDOWS\\System32\\shutdown -s");
}

Code for Ubuntu Linux
#include<stdio.h> 
void main() 
{  
system("shutdown -P now");
}  

Code for Window7

#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
{   
char shutdown;   
clrscr();   
gotoxy(15,5);
printf("Shutdown your computer now ? (y/n)\n\n\t Answer : ");   
gotoxy(20,7);
scanf("%c",&shutdown);   
if (shutdown == 'y' || shutdown == 'Y')      
{
system("C:\\WINDOWS\\System32\\shutdown \s");
}

Save program with '.c' extension.
for example shutdown.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.
  

Thank you for read post.

Captcha in C Language


Captcha in C Language (Turbo c )




If you have window xp then set this path "c:\\tc\\bgi".
For example  initgraph(&amp;getdevice,&amp;getmode,"c:\\tc\\bgi"); 
Write down  code for Captcha

#include<graphics.h>
#include<stdlib.h>

main()
{
   int i = 0, key, num, hx, getdevice = DETECT, getmode,color,maxx,maxy;
   char c[10];


   initgraph(&amp;getdevice,&amp;getmode,"c:\\turboc3\\bgi");


   setcolor(15);
   maxx=getmaxx();
   maxy=getmaxy();
   bar(0,0,maxx,maxy);
    hx = maxx/2;
    setcolor(0);
   settextstyle(1,0,1);
   outtextxy(hx,125,"");
   outtextxy(hx-50,180,"CAPTCHA");
   outtextxy(hx-100,150,"Press escape key to exit...");
   settextstyle(5,0,5);
   settextjustify(1,2);
   setviewport(100,200,600,400,1);
   setcolor(color);

   while(1)
   {
      while(i
&lt; 6)
    {
     num = random(3);

     if ( num == 0 )
        c[i] = 65 + random(26);     /* ASCII value of 65 to 90 is  A  to Z */
     else if ( num == 1)
        c[i] = 97 + random(26);     /* ASCII value of 97 to 122 is  a  to z */
     else
        c[i] = 48 + random(10);     /* ASCII value of 48 to 57 is 0 to 9 */
     i++;
      }
      c[i] = '\0';
      color=random(getmaxcolor());
      setcolor(color);
      outtextxy(210,100,c);

      key = getch();

      if( key == 27 )                     /* ASCII value of 27 is  escape key*/
     exit(0);
      clearviewport();
      i = 0;
   }
}

  
Save programm with '.c' extension.
for example captcha.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.


Now see  Captacha in C language.
  
Thank you for read my post.

Moving your name on screen in Computer Graphics


If you have WindowXP  then set this path  "c:\\tc\\bgi".
  
Why this path we are set?
 because we set BGI  file ,that is graphical file.
In short we are just set the path of "BGI" folder 

Write down given below code.
 
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<stdio.h>

void main() 
{
    int getdevice=DETECT,getmode,i=1,c,x,y;
   initgraph(&amp;getdevice,&amp;getmode,"c:\\turboc3\\bgi"); 
    while(i)
    {
        if(kbhit())
        {
              break;
        }
        x=random(getmaxx());
        y=random(getmaxy());
        c=random(getmaxcolor());
        settextstyle(4,0,5);
        cleardevice();
        setcolor(c);
        outtextxy(x,y,"Hitesh Rupchandani");
        delay(1000);
    }

    getch();
    closegraph();
}

Here my name Hitesh Rupchandani so you can add your name.
after save program with '.c' extension.
for example myname.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.


Now see the moving your name in screen

Find your .exe file of this program and other program

Go in My Computer .

In search box  'programname.exe'

for example myname.exe 



If you have any error or query ,you will ask me.

Thank you for read my post .