Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

I am using the OnlineGDB VB compiler. Does anyone know how to make a beep sound, or any sound?

+8 votes
asked Aug 7, 2020 by scott weingardt (200 points)

2 Answers

+2 votes
answered Aug 10, 2020 by Peter Minarik (86,130 points)
edited Aug 10, 2020 by Peter Minarik

The Bell Code/Character

In a Unix/Linux terminal, there is a special character that triggers the terminals bell (chime). If this character is "printed", then you'll hear a small beeping sound. Obviously, this does not work on Windows platforms (for that, one can find an answer here.)

This special character has the code 7, in C the escape sequence for it is '\a'. All you need to do is just to print it. See the example below. Also, you can read a bit more about it here.

A C Code Sample

#include <stdio.h>

int main(int argc,char *argv[])
{
    printf("\a");
    return 0;
}

Visual Basic

I don't use Visual Basic. But if it does not support terminals and thus the bell character, then probably you cannot do it. The reason is, that while Visual Basic has it's own sound library functions, it will run on the server and if any, the sounds would be produced there, not in your browser. :(

commented Aug 10, 2020 by scott weingardt (200 points)
Thanks Peter!!
0 votes
answered Dec 11, 2020 by Arun Pantham (140 points)
#include <stdio.h>

int main()
{
    for(int i=0;i<7;i++)
    {
        printf("%c",'\0'+7);
          
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...