banner



How To Check C++ Version In Windows 10 Cmd

How to Compile C Program in Command Prompt?

Last updated on Mar 26,2022 359.8K Views


How to Compile C Programme in Control Prompt?

We commonly utilise a compiler with a graphical user interface, to compile our C programme. This tin too be done past using cmd. The command prompt has a ready of steps we need to perform in club to execute our program without using a GUI compiler. In this article we would be agreement how to compile C program in control prompt.

So let us get with this article on how to compile C progam in control prompt,

How to Compile C Plan in Control Prompt?

STEP 1:

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

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

Create a c program and store it in your system. I have 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 main() { int num, original, rem, sum = 0; printf("Enter a three 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; }        

Stride 3:

Change the working directory to where you have your C program. You can practise that by using the control 'cd', which changes the directory. We need to pass the name of the directory in which the program is stored.

Example: >cd Desktop

Our plan is already in the user directory and so, we don't need to modify it.

Footstep 4:

The next step is to compile the plan. To exercise this we need to utilize the control gcc followed past the name of the program we are going to execute. In our case, we will use Armstrong.c.

Output - How to Compile C Program In CMD - Edureka

Subsequently this, an executable file will be created in the directory that your c file exists in. Eg: Armstrong.exe

Stride 5:

In the next stride, we can run the program. This is done by but giving the proper noun of the executable file without whatsoever extension. On giving this nosotros will become 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 nosotros come to the end of this blog on 'How To Compile C program in Command Prompt'. I hope you plant this informative and helpful, stay tuned for more tutorials on similar topics.You may too checkout our training programme to go in-depth knowledge on jQuery forth with its various applications, you canenroll hither for live online grooming with 24/7 support and lifetime access.

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

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

Posted by: chavisiont1981.blogspot.com

0 Response to "How To Check C++ Version In Windows 10 Cmd"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel