- 1
Q - make a function which checks if the number is prime or not and should return value in true and false. Is the coding alright?
#include <iostream> using namespace std; bool prime (int num); { int i,num; cout<<"Enter the number:"; cin >> num; for (i=2: i<=num i++) { if (num%2==0) return bool prime = false } else { return bool prime = true } int main () { int n; prime (int n); return 0;
6 Respuestas
+ 1
Does it run?
+ 1
Dipanjan Basu you have a lot of errors, please do not get me wrong but kindly study functions more.
Hope this helps.
Edit: 0 means false and 1 means true in the output.
https://code.sololearn.com/cf1LF2U7Te6f/?ref=app
+ 1
Avinesh no no absolutely not bro. It's just that I am not comfortable with functions completely. Thank you so much for helping out always! :)
0
It shows an error in the second bracket '{' it dint show any error otherwise till this
0
Avinesh yes it shows some errors if I remove the brackets could you correct it for me?
0
~ swim ~ just started with it 2 months