online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <stdio.h> // ν‘œμ€€ μž…μΆœλ ₯ κ΄€λ ¨ κΈ°λŠ₯을 μ œκ³΅ν•˜λŠ” 헀더 파일 #include <math.h> // μˆ˜ν•™ ν•¨μˆ˜λ₯Ό μ œκ³΅ν•˜λŠ” 헀더 파일 int isPrime(int num); // μ†Œμˆ˜λ₯Ό νŒλ³„ν•˜λŠ” μ‚¬μš©μž μ •μ˜ ν•¨μˆ˜ μ„ μ–Έ int isPrime(int num) { if (num <= 1) { return 0; } // num이 1보닀 μž‘κ±°λ‚˜ κ°™μœΌλ©΄ 0을 λ°˜ν™˜ // 2λΆ€ν„° μž…λ ₯된 μ •μˆ˜μ˜ μ œκ³±κ·ΌκΉŒμ§€ 반볡 μˆ˜ν–‰ for (int i = 2; i <= sqrt(num); i++) { if (num % i == 0) { return 0; } } return 1; } int main(void) { int num; // isPrime() ν•¨μˆ˜μ˜ λ§€κ°œλ³€μˆ˜λ‘œ, ν•¨μˆ˜ λ‚΄λΆ€μ—μ„œ μ‚¬μš©λ˜λŠ” μ§€μ—­ λ³€μˆ˜ printf("μ •μˆ˜λ₯Ό μž…λ ₯ν•˜μ„Έμš”: "); scanf("%d", &num); // λ°˜ν™˜κ°’μ— 따라 μ†Œμˆ˜ μ—¬λΆ€ λ©”μ‹œμ§€ 좜λ ₯ if (isPrime(num)) { printf("%dλŠ” μ†Œμˆ˜μž…λ‹ˆλ‹€.\n", num); } else { printf("%dλŠ” μ†Œμˆ˜κ°€ μ•„λ‹™λ‹ˆλ‹€.\n", num); } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue