banner



How To Run C Code On Windows

How to Compile C Programme in Command Prompt?

Last updated on Mar 26,2022 329.3K Views


How to Compile C Plan in Command Prompt?

We normally use a compiler with a graphical user interface, to compile our C program. This can also be washed past using cmd. The control prompt has a set of steps we demand to perform in order to execute our program without using a GUI compiler. In this article we would be understanding how to compile C plan in command prompt.

And then let united states get with this article on how to compile C progam in control prompt,

How to Compile C Program in Command Prompt?

STEP ane:

Run the command 'gcc -v' to bank check if you have a compiler installed. If not you need to download a gcc compiler and install information technology. You can search for cmd in your windows system to open the command prompt.

Output - How to Compile C Program In CMD - EdurekaFootstep ii:

Create a c program and store it in your system. I accept written a program to find the Armstrong Number and store it in the directory user. We would be using following code.

            #include <stdio.h> int primary() { int num, original, rem, sum = 0; printf("Enter a 3 digit Number: "); scanf("%d", &num); original = num; while (original != 0) { rem = original%10; sum =sum + rem*rem*rem; original =original/ x; } if(sum == num) printf("%d is an Armstrong number.",num); else printf("%d is not an Armstrong number.",num); return 0; }        

Footstep 3:

Alter the working directory to where yous have your C program. You can do that past using the command 'cd', which changes the directory. We need to laissez passer the name of the directory in which the program is stored.

Example: >cd Desktop

Our program is already in the user directory so, we don't demand to change information technology.

STEP 4:

The next step is to compile the program. To practice this nosotros need to use the command gcc followed by the name of the program nosotros are going to execute. In our example, we will use Armstrong.c.

Output - How to Compile C Program In CMD - Edureka

After this, an executable file volition exist created in the directory that your c file exists in. Eg: Armstrong.exe

STEP 5:

In the next step, we can run the program. This is washed by simply giving the name of the executable file without whatsoever extension. On giving this nosotros volition get an output. Here, our Armstrong code is executed and we got output for this code.

Output - How to Compile C Program In CMD - Edureka

With this we come up to the end of this blog on 'How To Compile C plan in Command Prompt'. I promise you establish this informative and helpful, stay tuned for more than tutorials on similar topics.Yous may also checkout our training program to make it-depth cognition on jQuery along with its diverse applications, you canenroll here for live online training with 24/seven support and lifetime access.

Got a question for us? Mention them in the comments section of  this web log and we will become back to you.

How To Run C Code On Windows,

Source: https://www.edureka.co/blog/how-to-compile-c-program-in-command-prompt/

Posted by: trujillowito2001.blogspot.com

0 Response to "How To Run C Code On Windows"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel