Sujal Singhania
Sujal Singhania

Reputation: 21

My C code is not running in Microsoft VS CODE

#include <stdio.h>

int main()
{
    int a,b;
    printf("Enter the value of a\n");
    scanf("%d",&a);
    printf("Enter the value of b\n");
    scanf("%d",&b);
    printf("The sum of a and b is %d", a + b);
    return 0;
}

When i run this code in Microsoft Visual Code the code doesn't stop executing nor do i get the output. It starts running but it does not stop. I am also not getting any output. Other type of code is working perfectly fine. Anyone can help me with this? click here for image from vscode showing the running window

Upvotes: 1

Views: 54414

Answers (5)

AsharSi
AsharSi

Reputation: 23

The main reason why code is not running is because it is running in "Output" Window, which I had shown in the linked Image. If you want to run code properly then you have to run it in "Terminal" Window.

For running your code in "Terminal" window you have to follow these steps: Step 1: Open Settings. Step 2: Then type "Run in Terminal" in search box of the setting. Scroll below and find that setting.Install code runner if you haven't. Step 3: Tick the box which is in 2nd line.

After that your code will run properly.

Upvotes: 2

Lizagodziashvili
Lizagodziashvili

Reputation: 3

I had exact same problem and it turns out I forgot to save the code:)

Upvotes: -4

Oussama
Oussama

Reputation: 26

Code runner extension runs code in the output file which can not be interacted with. You have to change it so it runs in the terminal. Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration. Find and check the box Run in Terminal.

Upvotes: 0

Kumkum Mittal
Kumkum Mittal

Reputation: 21

The code you have written is 100% correct. Take care of the following things, check it out, if you have done them:

  1. Install gcc in your system. gcc helps u compile c or c++ codes.
  2. Install a C/C++ extension from the extensions section in the visual studio code.
  3. At last, if the situation is still the same, try to re-install the visual studio code.

I hope, this might helps you. If you liked my suggestion, please press the upvoke button to motivate me to write such answers for you.

Thanks!

Upvotes: 2

Debanjan Karmakar
Debanjan Karmakar

Reputation: 1

if this thing happens again first again try to execute the same code with some other IDE or run your code separately with CMD or PowerShell.

Upvotes: 0

Related Questions