Variables and Keywords in C

Samual Sam
Updated on 24-Jun-2020 10:52:39

12K+ Views

VariablesIn C language, variables are the storage place where some form of data is stored. Different variables require different amount of memory on which a set of operations is applied.A variable name cannot start with a number. It can consist of alphabets, number, underscore “_”.Here is the syntax of declaring variables in C language, type variable_name;Here is the syntax of multiple variables declaration in C language, type variable_name1, variable_name2, variable_name3;The following is an example of variables in C language, Example Live Demo#include int main() {    char a1 = 'H';    int b = 90, c = 150;    float ... Read More

strchr Function in C++

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

468 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

strcat vs strncat in C++

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

773 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

strncat in C++

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

571 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

strpbrk in C++

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

340 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

Multiply Two Matrices by Passing Matrix to Function in C++

Ankith Reddy
Updated on 24-Jun-2020 09:55:04

2K+ Views

A matrix is a rectangular array of numbers that is arranged in the form of rows and columns.An example of a matrix is as follows.A 3*4 matrix has 3 rows and 4 columns as shown below.8 6 3 5 7 1 9 2 5 1 9 8A program that multiplies two matrices by passing the matrices to functions is as follows.Example Live Demo#include using namespace std; void MatrixMultiplication(int a[2][3],int b[3][3]) {    int product[10][10], r1=2, c1=3, r2=3, c2=3, i, j, k;    if (c1 != r2) {       cout

Set Style for Pagination with CSS

George John
Updated on 24-Jun-2020 09:50:08

127 Views

You can try to run the following code to style pagination with CSSExampleLive Demo                    .demo {             display: inline-block;          }          .demo a {             color: red;             float: left;             padding: 7px 10px;               text-decoration: none;          }                     Our Quizzes                          

CSS align-content Property

Smita Kapse
Updated on 24-Jun-2020 09:45:50

159 Views

Align flex lines with CSS align-content property. You can try to run the following code to implement the align-content property. It adds space around the items:ExampleLive Demo                    .mycontainer {             display: flex;             background-color: orange;             align-content: space-between;             height: 150px;             width: 600px;             flex-wrap: wrap;          }          .mycontainer > div {             background-color: white;             text-align: center;             line-height: 40px;             font-size: 25px;             width: 100px;             margin: 5px;          }                     Quiz                Q1          Q2          Q3          Q4          Q5          Q6          Q7          Q8          

Remove All Non-Alphabet Characters from a String in C++

Arjun Thakur
Updated on 24-Jun-2020 09:44:44

781 Views

A string is a one-dimensional character array that is terminated by a null character. It may contain characters, digits, special symbols etc.A program to remove all characters in a string except alphabets is given as follows.Example#include using namespace std; int main() {    char str[100] = "String@123!!";    int i, j;    cout

Find Factorial of a Number Using Recursion in C++

Arjun Thakur
Updated on 24-Jun-2020 09:42:22

15K+ Views

Factorial of a non-negative integer n is the product of all the positive integers that are less than or equal to n.For example: The factorial of 4 is 24.4! = 4 * 3 * 2 *1 4! = 24The factorial of an integer can be found using a recursive program or an iterative program.The following program demonstrates a recursive program to find the factorial of a number −Example Live Demo#include using namespace std; int fact(int n) {    if ((n==0)||(n==1))    return 1;    else    return n*fact(n-1); } int main() {    int n = 4;    cout

Advertisements