answersLogoWhite

0


Best Answer

#include<iostream.h>

int CheckPrime(int number){

for(int i=2;i<number;i++){

if(number%i==0)

return 0;

}

return 1;

}

void main()

{

int num=7;

cout<<CheckPrime(num);

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In C programming Write a function that returns 1 if its argument is a prime number and returns zero otherwise?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

What is different between a subroutine and function in vb.net?

Function returns a value but sub procedure do not return a value.


What sql function returns the numeric position of a named string?

SUBSTR


Date functions in sql?

Dates in SQL can be confusing for beginners since the format of the date in the database must match the date format entered when inserting data. Datetime is often used in place of the date in various situations. In MySQL RDBMS, the default date functions are: Sr.No. Function &amp; Description 1 ADDDATE() Adds dates 2 ADDTIME() Adds time 3 CONVERT_TZ() Converts from one timezone to another 4 CURDATE() Returns the current date 5 CURRENT_DATE(), CURRENT_DATE Works the same as CURDATE() 6 CURRENT_TIME(), CURRENT_TIME Works the same as CURTIME() 7 CURRENT_TIMESTAMP(), CURRENT_TIMESTAMP Works the same as NOW() 8 CURTIME() Returns the current time 9 DATE_ADD() Adds two dates 10 DATE_FORMAT() Formats date as specified 11 DATE_SUB() Subtracts two dates 12 DATE() Extracts the date part of a date or datetime expression 13 DATEDIFF() Subtracts two dates 14 DAY() Synonym for DAYOFMONTH() 15 DAYNAME() Returns the name of the weekday 16 DAYOFMONTH() Returns the day of the month (1-31) 17 DAYOFWEEK() Returns the weekday index of the argument 18 DAYOFYEAR() Returns the day of the year (1-366) 19 EXTRACT Extracts part of a date 20 FROM_DAYS() Converts a day number to a date 21 FROM_UNIXTIME() Formats date as a UNIX timestamp 22 HOUR() Extracts the hour 23 LAST_DAY Returns the last day of the month for the argument 24 LOCALTIME(), LOCALTIME Synonym for NOW() 25 LOCALTIMESTAMP, LOCALTIMESTAMP() Synonym for NOW() 26 MAKEDATE() Creates a date from the year and day of year 27 MAKETIME Returns a time value calculated from the hour, minute and second arguments. 28 MICROSECOND() Returns the microseconds from argument 29 MINUTE() Returns the minute from the argument 30 MONTH() Return the month from the date passed 31 MONTHNAME() Returns the name of the month 32 NOW() Returns the current date and time 33 PERIOD_ADD() Adds a period to a year-month 34 PERIOD_DIFF() Returns the number of months between periods 35 QUARTER() Returns the quarter from a date argument 36 SEC_TO_TIME() Converts seconds to 'HH:MM:SS' format 37 SECOND() Returns the second (0-59) 38 STR_TO_DATE() Converts a string to a date 39 SUBDATE() When invoked with three arguments a synonym for DATE_SUB() 40 SUBTIME() Subtracts times 41 SYSDATE() Returns the time at which the function executes 42 TIME_FORMAT() Formats as time 43 TIME_TO_SEC() Returns the argument converted to seconds 44 TIME() Extracts the time portion of the expression passed 45 TIMEDIFF() Subtracts time 46 TIMESTAMP() With a single argument this function returns the date or datetime expression. With two arguments, the sum of the arguments 47 TIMESTAMPADD() Adds an interval to a datetime expression 48 TIMESTAMPDIFF() Subtracts an interval from a datetime expression 49 TO_DAYS() Returns the date argument converted to days 50 UNIX_TIMESTAMP() Returns a UNIX timestamp 51 UTC_DATE() Returns the current UTC date 52 UTC_TIME() Returns the current UTC time 53 UTC_TIMESTAMP() Returns the current UTC date and time 54 WEEK() Returns the week number 55 WEEKDAY() Returns the weekday index 56 WEEKOFYEAR() Returns the calendar week of the date (1-53) 57 YEAR() Returns the year 58 YEARWEEK() Returns the year and week


What is the difference between the PMT and PPMT functions in Excel?

The PPMT function returns the amt. of interest in a specified instalment number whereas the PMT function returns the amt. of interest in every EMI payment.


How can you check if a variable is a string or an integer in PHP?

Integers - The "is_int()" function can be used to check if a variable is has an integer for its value. ---- is_int($variable); // Returns true if $variable is an integer - otherwise false ---- Numeric Strings - Numeric strings are strings with numbers (or things that count as numbers) in them. Numeric-string variables are not integer variables. Numeric-string variables are passed on through forms, instead of integer variables - if you were wondering. Check form values using string formats, and not integer formats. The "is_numeric()" function can be used to check if a variable is a string with numbers - and only numbers - in it (except things that add up to be numbers). ---- is_numeric($variable); // Returns true if $variable is a string, and only contains numbers (broadly speaking) - false otherwise ---- Strings - String values are just text, basically. String variables can contain integers, but that does not make it an integer-type variable - it makes it a numeric string variable. The "is_string" function can be used to check if a variable contains the value of a string. ---- is_string($variable); // Returns true if $variable is a string - false otherwise

Related questions

Describe a chicken using a programming language?

chicken is a function which takes argument as grain type and returns egg. egg chicken(grain x);


Write a function prime that return 1 if its argument is a prime and returns 0 otherwise?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt;main() { }


A function prime that returns if its argument is a prime no or returns zero?

prime number


An argument takes a value or values and performs an operation?

In programming, an argument takes a value or vales and performs an operation is called a function or method. If a method does not return a value, it is described as 'void'.


How does the compiler differentiate the statement and function in C programming?

statement should not return a value but function returns a value


What are the conditional logic functions in computer applications?

Not sure what you are asking here, but here is my best guess.COMPUTER PROGRAMMING APPLICATIONS:IF - If a condition exists, do something, if not, do something else.CASE - If a condition equals CASE1 do this; if CASE2 do this; etc.WHILE - If a condition remains, keep doing something until the condition changes.EXCEL:AND(logical1,logical2,...) - tests whether the logical arguments are TRUE or FALSE. If they are all TRUE, the AND function returns TRUE to the cell. If any are FALSE, the AND function returns FALSE.IF(logical_test,value_if_true,value_if_false) - tests whether the logical_test expression is TRUE or FALSE. If TRUE, the IF function returns the value_if_true argument. If FALSE, the IF function returns the value_if_false argument.IFERROR(value,value_if_error) - tests whether the value expression is an error. IFERROR returns value_if_error if the expression is an error, or value of the expression if it is not an error.NOT(logical) - tests whether the logical argument is TRUE or FALSE. If TRUE, the NOT function returns FALSE. If FALSE, the NOT function returns TRUE.OR(logical1,logical2,...) - tests whether the logical arguments are TRUE or FALSE. If any are TRUE, the OR function returns TRUE. If all are FALSE, the OR function returns FALSE.FALSE() - takes no argument and simply enters logical FALSE in its cell.TRUE() - takes no argument and simply enters logical TRUE in its cell.


What is a variable that is used within a function?

If the variable is declared within the function body, it is a local variable, one that is local to the function. Local variables fall from scope when the function returns, they are only accessible within the function. However, local variables can be returned by value, which creates an automatic variable that is returned to the caller. If the caller does not store the return value, the automatic variable falls from scope when the expression containing the function call ends. However, the expression may evaluate the return value without storing it. Note that functions cannot return local variables by reference since the local variable falls from scope when the function returns. If the variable is passed as an argument to the function, then the variable is a parameter of the function. Arguments may be passed by value or by reference, depending upon the function signature. Passing by value means the function parameter is a copy of the argument (if the argument is an object, the object's copy constructor is invoked automatically). Thus any changes made to the parameter within the function are not reflected in the argument that was originally passed, and the parameter will fall from scope when the function returns. However, the value of the parameter can be returned as previously explained. Passing by reference means the function parameter refers directly to the argument that was passed. Thus any changes made to the parameter are reflected in the argument. Parameters that are declared as constant references assure the caller that the reference's immutable members will not be altered by the function. If the parameter is a non-const reference but the caller does not wish changes to be reflected in the argument, the caller should pass a copy of the argument instead.


What is the meaning of fabs in quadratic equation in c program?

In the C Programming Language, the fabs function returns the absolute value of a floating-point number


Difference between sizeof and strlen?

The sizeof operator returns the total size, in bytes, of the given operand, whereas the strlen function returns the number of characters in the argument up to but not including the first null-terminator.Consider a character buffer allocated 50 bytes to which you assign the string "Hello world". The sizeof operator will return 50, but the strlen function returns 11.


A function takes the exponential function's output and returns the exponential function's input?

A __________ function takes the exponential function's output and returns the exponential function's input.


What is yywrap?

yywrap() is function used by yaac parser to deal with end of file processing.if end of file occurs then it returns 1 otherwise 0.


Function returns the value true if at least one argument is true and false if all arguments are false in Microsoft Excel?

You need to use the OR function. You could have something like this:=OR(A2>5,A4>10,A6>20)