Is it ram problem?

Pages: 12
Every program i create its take 2 sec to execute
No.
Your computer is probably just slow on it's own. This has nothing to do with your RAM.
Its probably a hard drive problem or OS issue.
but my PC is core i7
Which OS are you using?
How much RAM do you have?
Are you using any anti-virus software? If so, which one?
What compiler/ide are you using and what exactly do you mean it takes 2 seconds to execute? If you run your program from the command line / terminal do you still have the 2 second issue?
Do you mean the program starts to run 2 seconds after you hit the run button?
Maybe an example is a good idea.
sometimes 0.037 sec sometimes 4 sec why?is it my ram problem?i using windows 10 now by the way
Please provide an example of a short program that takes a long time to run.

Are you sure it takes 2 seconds to *run*? Maybe you are always compiling the program and running it too.
what u mean?
I mean a C++ program has to be compiled and linked into an executable file. The compilation and linking takes time, but only has to be done once (unless the C++ code changes of course). So my question is whether you are just running the executable file, or are you recompiling the program every time?
It's more then likely to be your antivirus OP. Windows 10 comes with a built in edition of Windows Defender that is set to scan non-whitelisted, non-signed executables at the time of access. My suggestion is to whitelist the directory that you keep your projects in, of course this has some obvious downsides such as when you are compiling other people's code, but as long as you don't do anything too stupid you should be fine. If you have a supplementary\alternative AV suite then it is likely to be doing the same thing as well.

If you suspect that it is RAM for whatever reason then why don't you just open Resource Manager and look?: http://windows.microsoft.com/en-us/windows7/open-resource-monitor
Bad RAM causes whole system instability, generally in the form of crashes or random I/O errors.
Low RAM (i.e. when the amount of memory that active processes are currently using is greater than the amount of physical memory) affects the performance of all processes, both user and system. Furthermore, a system that's in a thrashing state is basically unusable.
SO DO I NEED TO REPLACE RAM?
NO
why
Gone full circle boys.
It might be useful to know what all parts of a computer do:

First of all, there's the processor, which executes the code. It is the heart of the computer. It fetches instructions and executes them. The speed of the processor usually determines the speed of your computer. To store data, it needs some external memory.

The external memory is called RAM. RAM is nothing more than storage, having more RAM rarely adds to the speed of a computer.

Now there's one gotcha here, the operating system. The operating system might support swapping (as most modern systems do), this means that if you run out of RAM, the operating system will write unused RAM to your (slow) hard drive and fetch it back when required.

Under normal circumstances this rarely ever happens. You usually have more than enough RAM to execute lots of processes at once. But in the rare case you try to execute a lot of processes requiring 1GB per process, you might trigger this. When this happens, your entire system slows down, not just one process. So you don't seem to have problems with your RAM.

What might be happening in your case is that you are:

a: executing hundreds of processes at once, and the OS lets your program wait a while before giving it time to execute.
b: you hit "compile and run" in your IDE. This will cause a recompile of your program whenever you changed a source file. Compilation is a complicated process, and might take a while (2 seconds for simple projects, more for larger projects). This is most likely the case.

But since we really want to rule out everything, try compiling and running this process:

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <ctime>

int main()
{
    std::clock_t oldtime = std::clock();
    for(int i = 0; i < 100; ++i)
        std::cout << "Iteration " << i << std::endl;
    std::clock_t newtime =  std::clock() - oldtime;
    std::cout << "It took " << (((double)newtime) / CLOCKS_PER_SEC) << " seconds" << std::endl;
    return 0;
}


This code measures the number of seconds it takes to actually execute the process. If this value is high and varies wildly, then it might be a problem related to your OS not having time to execute your program, but otherwise, it's probably an error you make yourself.

Note that I put the important parts in bold, be sure to actually read all the parts.
Pages: 12