Skip to content
- Tutorials
- Python Tutorial
- Taking Input in Python
- Python Operators
- Python Data Types
- Python Loops and Control Flow
- Python Functions
- Python OOPS Concept
- Python Data Structures
- Python Exception Handling
- Python File Handling
- Python Exercises
- Java
- Java Programming Language
- Java Collections
- Java 8 Tutorial
- Java Programs
- Java Interview Questions
- Java Exercises
- Java Quiz
- Java Projects
- Advance Java
- Programming Languages
- System Design
- Interview Corner
- Computer Science Subjects
- DevOps
- Linux
- Software Testing
- Databases
- Android
- Excel
- Mathematics
- Python Tutorial
- DSA
- Data Structures
- Algorithms
- Analysis of Algorithms
- Searching Algorithms
- Sorting Algorithms
- Greedy Algorithms
- Dynamic Programming
- Graph Algorithms
- Pattern Searching
- Recursion
- Backtracking
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Randomized Algorithms
- Branch and Bound
- Algorithms Tutorial
- DSA Tutorial
- Practice
- All DSA Problems
- Problem of the Day
- Company Wise Coding Practice
- GfG SDE Sheet
- Practice Problems Difficulty Wise
- Language Wise Coding Practice
- Curated DSA Lists
- Competitive Programming
- Company Wise SDE Sheets
- DSA Cheat Sheets
- Top Interview Questions
- Puzzles
- Data Science
- Web Tech
- Courses
-
Last Updated : 03 Apr, 2023
Summarize
Comments
Improve
The isdigit() in C is a function that can be used to check if the passed character is a digit or not. It returns a non-zero value if it’s a digit else it returns 0. For example, it returns a non-zero value for ‘0’ to ‘9’ and zero for others.
The isdigit() function is declared inside ctype.h header file.
C isdigit() Syntax
isdigit(int arg);
C isdigit() Parameters
This function takes a single argument in the form of an integer and returns the value of type int.
Note: Even though isdigit() takes an integer as an argument, the character is passed to the function. Internally, the character is converted to its ASCII value for the check.
C isdigit() Return Value
This function returns an integer value on the basis of the argument passed to it
- If the argument is a numeric character then it returns a non-zero value(true value).
- It returns zero(false value) if the argument is a non-numeric character.
Example: C Program to check whether the character is a digit or not using isdigit() Function
C
// C program to demonstrate isdigit()
#include <ctype.h>
#include <stdio.h>
// Driver Code
int
main()
{
// Taking input
char
ch =
'6'
;
// Check if the given input
// is numeric or not
if
(
isdigit
(ch))
printf
(
"Entered character is"
" numeric character"
);
else
printf
(
"Entered character is not"
" a numeric character"
);
return
0;
}
Output
Entered character is numeric character
Working of isdigit() function in C
The working of the isdigit() function is as follows:
- STEP 1: The isdigit() function takes the character to be tested as the argument.
- STEP 2: The ASCII value of the character is checked.
- STEP 3A: If the ASCII value of the character is between 48 ( i.e ‘0’ ) and 57 ( i.e. ‘9’ ), a non-zero value (TRUE) is returned.
- STEP 3B: If the ASCII value of the character is not between 48 ( i.e ‘0’ ) and 57 ( i.e. ‘9’ ), Zero value (FALSE) is returned.
Please Login to comment...
Similar Reads
isalpha() and isdigit() functions in C with cstring examples.
isalpha(c) is a function in C which can be used to check if the passed character is an alphabet or not. It returns a non-zero value if it's an alphabet else it returns 0. For example, it returns non-zero values for 'a' to 'z' and 'A' to 'Z' and zeroes for other characters.Similarly, isdigit(c) is a function in C which can be used to check if the pa
2 min read
wcscpy() function in C++ with Examples
The wcscpy() function is defined in cwchar.h header file. The wcscpy() function is used to copy a wide character string from source to destination. Syntax: wchar_t *wcscpy(wchar_t *dest, const wchar_t *src); Parameters: This method accepts the following two parameters: dest: specifies the pointer to the destination array. src: specifies the pointer
1 min read
wcscmp() function in C++ with Examples
The wcscmp() function is defined in cwchar.h header file. The wcscmp() function is used to compares two null terminating wide string and this comparison is done lexicographically. Syntax: int wcscmp(const wchar_t* str1, const wchar_t* str2); Parameters: This method takes the following two parameters: str1: This represents the pointer to the first s
2 min read
quick_exit() function in C++ with Examples
The quick_exit() function is defined in the stdlib header file. The quick_exit() function is used for normal termination of a process without completely cleaning the resources. If val is zero or EXIT_SUCCESS, it shows successful termination of program.If the value is non-zero or EXIT_FAILURE, it shows that the program is not successfully terminated
1 min read
btowc() function in C/C++ with Examples
The btowc() is a built-in function in C/C++ which converts a character to its wide character equivalent. It is defined within the cwchar header file of C++. Syntax: wint_t btowc( int ch ); Parameter:The function accepts a single mandatory parameter ch which specifies the single byte character to convert to it's wide character. Return Value: The fun
2 min read
wcsspn() function in C/C++ with Examples
The wcsspn() is a built-in function in C/C++ which returns the length of maximum initial segment of the wide string that consists of characters present in another wide string. It is defined within the cwchar header file of C++. Syntax: wcsspn(des, src) Parameters:The function accepts two mandatory parameters as described below. des: specifies to a
2 min read
wcslen() function in C++ with Examples
The wcslen() function is defined in cwchar.h header file. The function wcslen() function returns the length of the given wide string. Syntax: size_t wcslen(const wchar_t* str); Parameter: This method takes a single parameter str which represents the pointer to the wide string whose length is to be calculated. Return Value: This function returns the
2 min read
norm() function in C++ with Examples
The norm() function is defined in the complex header file. This function is used to return the squared magnitude of the complex number z. Syntax: template<class T> T norm (const complex<T>& z); Parameter: z: It represents the given complex number. Return: It returns the squared magnitude of the complex number. Time Complexity: O(1)
1 min read
sin() function for complex number in C++ with Examples
The sin() function for complex numbers is defined in the <complex> header file. This function is the complex version of the sin() function. This function is used to calculate the complex sine of the complex number z. This function returns the sine of the complex number z. Syntaxsin (z); Parameters z: This method takes a mandatory parameter z
2 min read
not1 and not2 function templates in C++ STL with Examples
These are functions which takes unary and binary function object(functors) and returns complement of that function objects. It can be usable in competitive programming to get complement of binary and unary functions. These functions are very useful when writing code for complement function is harder or lengthy. For example, if we want to delete con
3 min read
ios fail() function in C++ with Examples
The fail() method of ios class in C++ is used to check if the stream is has raised any fail error. It means that this function will check if this stream has its failbit set. Syntax: bool fail() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the stream has failbit set, else false. Example 1: /
1 min read
ios bad() function in C++ with Examples
The bad() method of ios class in C++ is used to check if the stream is has raised any bad error. It means that this function will check if this stream has its badbit set. Syntax: bool bad() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the stream has badbit set, else false. Time Complexity:
1 min read
ios setstate() function in C++ with Examples
The setstate() method of ios class in C++ is used to change the current state of this stream by setting the flags passed as the parameters. Hence this function changes the internal state of this stream. Syntax: void setstate(iostate state) Parameters: This method accepts the iostate as parameter which is the combination of goodbit, failbit, eofbit
2 min read
ios good() function in C++ with Examples
The good() method of ios class in C++ is used to check if the stream is good enough to work. It means that this function will check if this stream has raised any error or not. Syntax: bool good() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the stream is good, else false. Time Complexity: O
1 min read
ios eof() function in C++ with Examples
The eof() method of ios class in C++ is used to check if the stream is has raised any EOF (End Of File) error. It means that this function will check if this stream has its eofbit set. Syntax: bool eof() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if the stream has eofbit set, else false. Tim
1 min read
ios clear() function in C++ with Examples
The clear() method of ios class in C++ is used to change the current state of the specified flag by setting it. Hence this function changes the internal state of this stream. Syntax: void clear(iostate state) Parameters: This method accepts the iostate as parameter which is the flag bit to be set in this stream. It can be goodbit, failbit, eofbit o
2 min read
ios rdstate() function in C++ with Examples
The rdstate() method of ios class in C++ is used to read the internal state of this stream. Syntax: iostate rdstate() const; Parameters: This method does not accept any parameter. Return Value: This method returns the current internal state of this stream. Example 1: // C++ code to demonstrate // the working of rdstate() function #include <bits/
1 min read
ios operator() function in C++ with Examples
The operator() method of ios class in C++ is used to any error flag of this stream is set. This includes the failbit or the badbit. Syntax: operator void*() const; Parameters: This method does not accept any parameter. Return Value: This method returns a null pointer if any error bit is set of this stream. Example 1: // C++ code to demonstrate // t
1 min read
ios operator() function in C++11 with Examples
The operator() method of ios class in C++11 is used to any error flag of this stream is set. This includes the failbit or the badbit. Syntax: explicit operator bool() const; Parameters: This method does not accept any parameter. Return Value: This method returns false if any error bit is set of this stream, else true. Example 1: // C++ code to demo
1 min read
ios operator !() function in C++ with Examples
The operator!() method of ios class in C++ is used to any error flag of this stream is set. This includes the failbit or the badbit. Syntax: bool operator!() const; Parameters: This method does not accept any parameter. Return Value: This method returns true if any error bit is set of this stream, else false. Example 1: // C++ code to demonstrate /
1 min read
iomanip resetiosflags() function in C++ with Examples
The resetiosflags() method of iomanip library in C++ is used to reset the ios library format flags specified as the parameter to this method.Syntax: resetiosflags (ios_base::format_flag) Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be reset by this method.Return Value: This method does not retur
2 min read
iomanip setfill() function in C++ with Examples
The setfill() method of iomanip library in C++ is used to set the ios library fill character based on the character specified as the parameter to this method. Syntax: setfill(char c) Parameters: This method accepts c as a parameter which is the character argument corresponding to which the fill is to be set. Return Value: This method does not retur
2 min read
iomanip setbase() function in C++ with Examples
The setbase() method of iomanip library in C++ is used to set the ios library basefield flag based on the argument specified as the parameter to this method. Syntax: setbase (int base) Parameters: This method accepts base as a parameter which is the integer argument corresponding to which the base is to be set. 10 stands for dec, 16 stands for hex,
2 min read
setw() function in C++ with Examples
The setw() method of iomanip library in C++ is used to set the ios library field width based on the width specified as the parameter to this method. The setw() stands for set width and it works for both the input and the output streams. Syntax: std::setw(int n); Parameters: n: It is the integer argument corresponding to which the field width is to
2 min read
iomanip setprecision() function in C++ with Examples
The setprecision() method of iomanip library in C++ is used to set the ios library floating point precision based on the precision specified as the parameter to this method. Syntax: setprecision(int n) Parameters: This method accepts n as a parameter which is the integer argument corresponding to which the floating-point precision is to be set. Ret
2 min read
iomanip setiosflags() function in C++ with Examples
The setiosflags() method of iomanip library in C++ is used to set the ios library format flags specified as the parameter to this method.Syntax: setiosflags (ios_base::format_flag) Parameters: This method accepts format_flag as a parameter which is the ios library format flag to be set by this method.Return Value: This method does not returns anyth
1 min read
fill() function in C++ STL with examples
The fill() function in C++ STL is used to fill some default value in a container. The fill() function can also be used to fill values in a range in the container. It accepts two iterators begin and end and fills a value in the container starting from position pointed by begin and just before the position pointed by end. Syntax: void fill(iterator b
2 min read
fill_n() function in C++ STL with examples
The fill_n() function in C++ STL is used to fill some default values in a container. The fill_n() function is used to fill values upto first n positions from a starting position. It accepts an iterator begin and the number of positions n as arguments and fills the first n position starting from the position pointed by begin with the given value. Sy
2 min read
_Find_first() function in C++ bitset with Examples
The _Find_first() is a built-in function in C++ Bitset class which returns an integer that refers the position of first set bit in bitset. If there isn’t any set bit, _Find_first() will return the size of the bitset. Syntax: iterator bitset._Find_first() or int bitset._Find_first() Parameters: The function accepts no parameter. Return Value: The fu
2 min read
_Find_next() function in C++ bitset with Examples
The _Find_next() is a built-in function in C++ Bitset class which returns an integer which refers the position of next set bit in bitset after index. If there isn't any set bit after index, _Find_next(index) will return the size of the bitset. Syntax: iterator bitset._Find_next(index) or int bitset._Find_next(index) Parameters: The function accepts
2 min read
Article Tags :
Practice Tags :
Trending in News
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: writeApiUrl + 'suggestions/auth/' + `${post_id}/`, type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, success: function (result) { $('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['id']; var comment_text = comment['suggestion']; improvement_reason_html += `
${comment_text}
`; } $('.improvement-reasons_wrapper').html(improvement_reason_html); $('.improvement-bottom-btn').html("Create Improvement"); $('.improve-modal--improvement').hide(); $('.improvement-reason-modal').show(); }, error: function(e){ $('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ $('.improvement-reason-modal').hide(); } $('.improve-modal--improvement').show(); }); function loadScript(src, callback) { var script = document.createElement('script'); script.src = src; script.onload = callback; document.head.appendChild(script); } function suggestionCall() { var suggest_val = $.trim($("#suggestion-section-textarea").val()); var array_String= suggest_val.split(" ") var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(suggest_val.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `
${suggest_val}
`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').css("display","none"); // Update the modal content const modalSection = document.querySelector('.suggestion-modal-section'); modalSection.innerHTML = `
Thank You!
Your suggestions are valuable to us.
You can now also contribute to the GeeksforGeeks community by creating improvement and help your fellow geeks.
`; }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 5 Words and Maximum Character limit is 2000."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // load the captcha script and set the token loadScript('https://www.google.com/recaptcha/api.js?render=6LdMFNUZAAAAAIuRtzg0piOT-qXCbDF-iQiUi9KY',[], function() { setGoogleRecaptcha(); }); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.improvement-reason-modal').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { $('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ $('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); $('.improvement-reason-modal').hide(); } }, }); });