Found 27759 Articles for Server Side Programming

Ternary Operators in C/C++

karthikeya Boyini
Updated on 24-Jun-2020 10:57:13

1K+ Views

The operators, which require three operands to act upon, are known as ternary operators. It can be represented by “ ? : ”. It is also known as conditional operator. The operator improves the performance and reduces the line of code.Here is the syntax of ternary operator in C language, Expression1 ? Expression2 : Expression3Here is an example of Ternary Operators in C language, Example Live Demo#include int main() {    int a = -1;    double b = 26.4231;    int c = a? printf("True value : %lf", b):printf("False value : 0");    return 0; }OutputTrue value : 26.423100Expression1 ... Read More

sinh() function in C++ STL

Chandu yadav
Updated on 24-Jun-2020 10:57:45

79 Views

The sinh() function returns the hyperbolic sine of an angle given in radians. It is an inbuilt function in C++ STL.The syntax of the sinh() function is given as follows.sinh(var)As can be seen from the syntax, the function sinh() accepts a parameter var of data type float, double or long double. It returns the hyperbolic sine of var.A program that demonstrates sinh() in C++ is given as follows.Example Live Demo#include #include using namespace std; int main() {    double d = 5, ans;    ans = sinh(d);    cout

Sizeof operator in C

Samual Sam
Updated on 24-Jun-2020 10:58:13

18K+ Views

The sizeof operator is the most common operator in C. It is a compile-time unary operator and used to compute the size of its operand. It returns the size of a variable. It can be applied to any data type, float type, pointer type variables.When sizeof() is used with the data types, it simply returns the amount of memory allocated to that data type. The output can be different on different machines like a 32-bit system can show different output while a 64-bit system can show different of same data types.Here is an example in C language, Example Live Demo#include ... Read More

Typecasting in C

karthikeya Boyini
Updated on 24-Jun-2020 10:48:40

4K+ Views

Typecasting is a method in C language of converting one data type to another.There are two types of typecasting.1.Implicit Type casting − This conversion is done by the compiler. When more than one data type of variables are used in an expression, the compiler converts data types to avoid loss of data.Here is an example of implicit type casting in C language, Example Live Demo#include int main() {    int a = 10;    char b = 'S';    float c = 2.88;    a = a+b;    printf("Implicit conversion from character to integer : %d", a);    c = ... Read More

strpbrk() in C++

George John
Updated on 24-Jun-2020 10:47:19

215 Views

This is a string function in C++ that takes in two strings and finds the first occurrence of any character of string2 in string1. It returns the pointer to the character in string1 if there is any, otherwise returns NULL. This is not applicable for terminating NULL characters.The syntax of strpbrk() is given as follows −char *strpbrk(const char *str1, const char *str2)In the above syntax, strpbrk() returns the pointer to the first character in str1 that matches any character in str2.A program that demonstrates strpbrk() is given as follows.Example Live Demo#include #include using namespace std; int main() {   ... Read More

strncat() in C++

Ankith Reddy
Updated on 24-Jun-2020 10:49:01

354 Views

The function strncat() in C++ is used for concatenation. It appends the specified number of characters from the source string at the end of the destination string and returns a pointer to the destination string. The syntax of strncat() is given as follows.char * strncat ( char * dest, const char * src, size_t num );In the above syntax, the source string src is appended at the end of the destination string dest till num characters only.A program that demonstrates strcat() is given as follows.Example Live Demo#include #include using namespace std; int main() {    char str1[20] = "Programming ... Read More

Data Types in C

Raju Kumar
Updated on 24-Jun-2020 10:58:38

13K+ Views

Variables in C are associated with data type. Each data type requires an amount of memory and performs specific operations.There are some common data types in C −int − Used to store an integer value.char − Used to store a single character.float − Used to store decimal numbers with single precision.double − Used to store decimal numbers with double precision.The following table displays data types in C language −Data TypesBytesRangeshort int2-32, 768 to 32, 767unsigned short int20 to 65, 535unsigned int40 to 4, 294, 967, 295int4-2, 147, 483, 648 to 2, 147, 483, 647long int4-2, 147, 483, 648 to 2, ... Read More

strcat() vs strncat() in C++

Arjun Thakur
Updated on 24-Jun-2020 10:49:31

505 Views

Both strcat() and strncat() are predefined string functions in C++. Details about these are given as follows.strcat()This function is used for concatenation. It appends a copy of the source string at the end of the destination string and returns a pointer to the destination string. The syntax of strcat() is given as follows.char *strcat(char *dest, const char *src)A program that demonstrates strcat() is given as follows.Example Live Demo#include #include using namespace std; int main() {    char str1[20] = "Mangoes are ";    char str2[20] = "yellow";    strcat(str1, str2);    cout

strchr() Function in C++

Chandu yadav
Updated on 24-Jun-2020 10:49:57

306 Views

In C++, strchr() is a predefined function. It is used for string handling and it returns the first occurance of a given character in the string provided.The syntax of strchr() is given as follows.char *strchr( const char *str, int c)In the above syntax, str is the string that contains the character c. The strchr() function finds the first occurrence of c in str.A program that demonstrates the strchr() function is given as follows.Example Live Demo#include #include using namespace std; int main() {    char str[] = "strings";    char * c = strchr(str,'s');    cout

Tokens in C

karthikeya Boyini
Updated on 24-Jun-2020 10:50:32

15K+ Views

Tokens are the smallest elements of a program, which are meaningful to the compiler.The following are the types of tokens: Keywords, Identifiers, Constant, Strings, Operators, etc.Let us begin with Keywords.KeywordsKeywords are predefined, reserved words in C and each of which is associated with specific features. These words help us to use the functionality of C language. They have special meaning to the compilers.There are total 32 keywords in C.autodoubleintstructbreakelselongswitchcaseenumregistertypedefcharexternreturnunioncontinueforsignedvoiddoifstaticwhiledefaultgotosizeofvolatileconstfloatshortunsignedIdentifiersEach program element in C programming is known as an identifier. They are used for naming of variables, functions, array etc. These are user-defined names which consist of alphabets, number, underscore ‘_’. ... Read More

Advertisements