Reputation: 21
#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
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
Reputation: 3
I had exact same problem and it turns out I forgot to save the code:)
Upvotes: -4
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
Reputation: 21
The code you have written is 100% correct. Take care of the following things, check it out, if you have done them:
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
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