1

here's my full code -

#include<stdio.h>
int main()
{
    int a = 100;
    float b = 5.55;
    printf("my a = %d and my b = %f",a,b);
    printf("\a");
    return 0;

}

it runs perfectly and didn't gave any error but it also it didn't gave any sound beep or alarm sound.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • 3
    Check your speaker or other sound device and its connection to PC. Check if your terminal supports beeping. Check the volume configuration on your OS. – MikeCAT Aug 04 '21 at 14:21
  • 7
    The Beep character in ASCII is not guaranteed to be supported on all computers or operating systems. I can't remember the last time I heard a computer actually emit this sound. – Robert Harvey Aug 04 '21 at 14:23
  • 3
    Well this is one case where most online compilers won't help... – n. m. could be an AI Aug 04 '21 at 14:27
  • [Unable to get system beep to work in C using various methods](https://stackoverflow.com/q/4102273/995714), [How to produce beep sound using “\a” escape character?](https://stackoverflow.com/q/3845590/995714), [Can't get “\a” to output a beep sound](https://stackoverflow.com/q/6727518/995714), [C - printf(“\a”) won't sound an alert (duplicate)](https://stackoverflow.com/q/46728477/995714) – phuclv Aug 04 '21 at 14:55
  • [`\a` (BELL character) is not supposed to work on every modern system](https://en.wikipedia.org/wiki/Bell_character#:~:text=A%20program%20can%20get%20the,or%20do%20nothing%20at%20all.). I think it might help if you specify which operating system you might be targeting so that you might be able to find suitable platform-specific alternatives. – Ruks Aug 04 '21 at 15:00
  • @RobertHarvey: This is not an ASCII issue. Per C 2018 5.2.2 2, the character represented by escape sequence `\a` is intended to produce “an audible or visible alert.” – Eric Postpischil Aug 04 '21 at 15:02
  • @EricPostpischil: The spec may not cite the actual ASCII character, but the usual way to produce a beep in a terminal is to use ASCII character code 7. I would be very surprised if C implementations did anything else. You can call it "failure to adhere to the specification," if you like. – Robert Harvey Aug 04 '21 at 15:08
  • @RobertHarvey: This is not an ASCII or a support issue. `\a` produces an alert, and macoS, Linux, and Windows support this. OP has something in their configuration impeding it, such as sounds turned off or volume turned down. – Eric Postpischil Aug 04 '21 at 15:10

0 Answers0