How to write your first program in C/C++ using Command Prompt in Windows
Step 1: Install MinGW GCC Compiler for Windows Click Here to Download
Step 2: Open CMD (Command Prompt)
start notepad myfile.c <press enter>
Step 2: gcc myfile.c
–o myfile
Step 3: myfile.exe
Example: WAP for Factorial Calculation
#include<stdio.h>
int main()
{
int num,fact=1;
scanf("%d",&num);
for(int c=1; c<=num; c++)
{
fact = fact * c;
}
printf("%d",fact);
return (0);
}
Output: Go to the dir where you have saved the file.
Step 3: myfile.exe
Example: WAP for Factorial Calculation
#include<stdio.h>
int main()
{
int num,fact=1;
scanf("%d",&num);
for(int c=1; c<=num; c++)
{
fact = fact * c;
}
printf("%d",fact);
return (0);
}
Output: Go to the dir where you have saved the file.
Hope it works for You. For any doubts please comment.
Comments
Post a Comment