
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

16K+ Views
rand()The function rand() is used to generate the pseudo random number. It returns an integer value and its range is from 0 to rand_max i.e 32767.Here is the syntax of rand() in C language, int rand(void);Here is an example of rand() in C language, Example Live Demo#include #include int main() { printf("%d", rand()); printf("%d", rand()); return 0; }Output1804289383 846930886srand()The function srand() is used to initialize the generated pseudo random number by rand() function. It does not return anything.Here is the syntax of srand() in C language, void srand(unsigned int number);Here is an example of srand() in C ... Read More

7K+ Views
strdup() The function strdup() is used to duplicate a string. It returns a pointer to a null-terminated byte string. Syntax Here is the syntax of strdup() in C language, char *strdup(const char *string); Example Here is an example of strdup() in C language. #include #include int main() { char *str = "Helloworld"; char *result; result = strdup(str); printf("The string : %s", result); return 0; } Output The string : Helloworld strndup() The function strndup works similarly to the function strndup(). This function duplicates the string at most size bytes i.e. the given size in the function. It also returns ... Read More

7K+ Views
The function fflush(stdin) is used to flush the output buffer of the stream. It returns zero, if successful otherwise, returns EOF and feof error indicator is set.Here is the syntax of fflush(stdin) in C language,int fflush(FILE *stream);Here is an example of fflush(stdin) in C language,Example Live Demo#include #include int main() { char s[20] = "Helloworld"; printf("The string : %s", s); fflush(stdin); return 0; }OutputThe string : Helloworld

140 Views
The function ispunct() is used to check that the passing character is a punctuation or not. It returns zero, if it is not a punctuation, otherwise it returns a non-zero value.Here is the syntax of ispunct() in C language, int ispunct(int character);Here is an example of ispunct() in C language, Example Live Demo#include #include int main() { int a = '!'; int b = 'a'; if(ispunct(a)) printf("The character is a punctuation."); else printf("The character is not a punctuation."); if(ispunct(b)) printf("The character is a punctuation."); else printf("The character is not a ... Read More

220 Views
The function strspn() is used to calculate the length of substring of first string which is present in second string. It returns the length of that substring.Here is the syntax of strspn() in C language,size_t strspn(const char *string1, const char *string2);Here is an example of strspn() in C language,Example Live Demo#include #include int main() { const char s1[] = "Helloworld!"; const char s2[] = "Hello"; int length = strspn(s1, s2); printf("The length of string : %d", length); return 0; }OutputThe length of string : 5

287 Views
The function strcoll() is used to compare two strings using locale - specific collating sequence.It returns −zero, when both strings are same, greater than zero value when first string is greater than otherless than zero value, when first string is less than other.Here is the syntax of strcoll() in C language, int strcoll(const char *first_string, const char *second_string);Here is an example of strcoll() in C language, Example Live Demo#include #include int main () { const char s1[] = "Helloworld"; const char s2[] = "Blank"; char *result; result = strcoll(s1, s2); if(result > 0) ... Read More

1K+ Views
The function strpbrk() is used to find the first character of first string and matches it to any character of second string. It returns NULL, if no matches are found otherwise, it returns a pointer to the character of first string that matches to the character of second string.Here is the syntax of strpbrk() in C language, char *strpbrk(const char *string1, const char *string2)Here is an example of strpbrk() in C language, Example Live Demo#include #include int main () { const char s1[] = "Helloworld"; const char s2[] = "Blank"; char *result; result = strpbrk(s1, ... Read More

2K+ Views
Function scanf()The function scanf() is used to read formatted input from stdin in C language. It returns the whole number of characters written in it otherwise, returns a negative value.Here is the syntax of scanf() in C language, int scanf(const char *characters_set)Here is an example of scanf() in C language, Example Live Demo#include int main () { char s[20]; printf("Enter a string : "); scanf("%s", s); printf("Entered string : %s", s); return(0); }OutputEnter a string : Peter! Entered string : Peter!Function fscanf()The function fscanf() is used to read the formatted input from the given stream ... Read More

2K+ Views
Format Specifier %dThe format specifier %d takes integer value as a signed decimal integer value which means values should be decimal whether it is negative or positive.Here is an example of format specifier %d in C language, Example Live Demo#include int main() { int v1 = 7456; int v2 = -17346; printf("The value in decimal form : %d", v1); printf("The value in negative : %d", v2); return 0; }OutputThe value in decimal form : 7456 The value in negative : -17346Format Specifier %iThe format specifier %i takes integer value as an integer value which means ... Read More

762 Views
atol() FunctionThe function atol() converts string into a long integer. It returns zero, when no conversion is performed. It returns the converted long int value.Here is the syntax of atol in C++ language,long int atol(const char *string)Here is an example of atol() in C++ language,Example Live Demo#include using namespace std; int main() { long int a; char str[20] = "538756"; a = atol(str); cout