- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 34494 Articles for Programming
26K+ Views
Pointers are variables which stores the address of another variable. When we allocate memory to a variable, pointer points to the address of the variable. Unary operator (*) is used to declare a variable and it returns the address of the allocated memory. Pointers to an array points the address of memory block of an array variable.The following is the syntax of array pointers.datatype *variable_name[size];Here, datatype − The datatype of variable like int, char, float, etc.variable_name − This is the name of variable given by user.size − The size of array variable.The following is an example of array pointers.Example Live Demo#include ... Read More
1K+ Views
return statementThe return statement terminates the execution of function and it returns the control to the calling function. It calls the constructor as well as the destructor. It returns an integer value for “int main()”.The following is the syntax of return statement.return expression;Here,expression − The expression or any value to be returned.The following is an example of return statement.Example Live Demo#include using namespace std; class Method { public: Method() { cout
597 Views
The following is an example to swap strings.Example Live Demo#include #include int main() { char st1[] = "My 1st string"; char st2[] = "My 2nd string"; char swap; int i = 0; while(st1[i] != '\0') { swap = st1[i]; st1[i] = st2[i]; st2[i] = swap; i++; } printf("After swapping s1 : %s", st1); printf("After swapping s2 : %s", st2); return 0; }OutputAfter swapping s1 : My 2nd string After swapping s2 : My 1st stringIn the above program, two ... Read More
4K+ Views
When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static variable can be defined inside or outside the function. They are local to the block. The default value of static variable is zero. The static variables are alive till the execution of the program.Here is the syntax of static variables in C language, static datatype variable_name = value;Here, datatype − ... Read More
11K+ Views
The printf() and scanf() functions are required for output and input respectively in C. Both of these functions are library functions and are defined in the stdio.h header file.Details about the return values of the printf() and scanf() functions are given as follows −The printf() functionThe printf() function is used for printing the output. It returns the number of characters that are printed. If there is some error then it returns a negative value.A program that demonstrates this is as follows −Example Live Demo#include int main(){ char str[] = "THE SKY IS BLUE"; printf("The value returned ... Read More
2K+ Views
Details about getchar(), fgetc() and getc() functions in C programming are given as follows −The getchar() functionThe getchar() function obtains a character from stdin. It returns the character that was read in the form of an integer or EOF if an error occurs.A program that demonstrates this is as follows −Example Live Demo#include int main (){ int i; printf("Enter a character: "); i = getchar(); printf("The character entered is: "); putchar(i); return(0); }OutputThe output of the above program is as follows −Enter a character: G The character entered is: GNow ... Read More
3K+ Views
When static keyword is used, variable or data members or functions can not be modified again. It is allocated for the lifetime of program. Static functions can be called directly by using class name.Static variables are initialized only once. Compiler persist the variable till the end of the program. Static variable can be defined inside or outside the function. They are local to the block. The default value of static variable is zero. The static variables are alive till the execution of the program.Here is the syntax of static variables in C language, static datatype variable_name;Here, datatype − The datatype ... Read More
7K+ Views
The function pow() is used to calculate the power raised to the base value. It takes two arguments. It returns the power raised to the base value. It is declared in “math.h” header file.Here is the syntax of pow() in C language, double pow(double val1, double val2);Here, val1 − The base value whose power is to be calculated.val2 − The power value.Here is an example of pow() in C language, Example#include #include int main() { double x = 5.5; double y = 4.0; double p; p = pow(x, y); printf("The value : %lf", p); ... Read More