
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

13K+ Views
The task is to write C++ programs that calculates the sum of the digits of a given number. For example, if the number is 453, the sum of its digits would be 4 + 5 + 3 = 12. To solve this, we will extract each digit from the number and add them together. We will use basic programming concepts such as loops and arithmetic operations to achieve this. In this article, we will show you how to write a C++ program that takes a number as input and sums the digits of that number. Approaches for ... Read More

964 Views
In C++, the sizeof() operator is a unary operator which is used to calculate the size of any data type. Implementing sizeof() OperatorWe can use the #define directive to implement a macro that copies the behavior of the sizeof() operator for objects, though it will not be the same as the sizeof() operator. Syntax Following is the syntax of C++ macro to implement the sizeof(): #define any_name(object) (char *)(&object+1) - (char *)(&object) Here, any_name : The name you want to give to your own sizeof() operator. Note: The main benefit of using MACROS is defining by once ... Read More

4K+ Views
In C++, when a class inherits from another class, it inherits all members from parent class, but their accessibility are based on access specifiers. Key Points on What Inherits from Parent Class Following are some points on derived class inherits from its parent: The derived class can inherit data members, member functions of base class. If the data members are public, they can be accessed by derived class, same class and outside the class. If data members are protected, they can be accessed by derived and same ... Read More

4K+ Views
You can print the numbers from 1 to 100 without a loop by using the various methods like recursive function and goto statement that print the list of integers.The following are the approaches to print the numbers from 1 to 100: Using Recursion As we know, recursion is the process of calling the function itself. Here, we use the recursive function to accept an integer and set the iteration of plus 1 without the logic of loop and get the expected outcome. Example In this example, we use an if statement to check whether the given integer is less than ... Read More

150 Views
The function isgraph() is used to check that the passed character has a graphical representation or not. It is declared in “ctype.h” header file.Here is the syntax of isgraph() in C language, int isgraph(int char);Here is an example of isgraph() in C language, Example Live Demo#include #include int main() { int a = ''; int b = '8'; int c = 's'; if(isgraph(a)) printf("The character has graphical representation"); else printf("The character isn’t having graphical representation"); if(isgraph(b)) printf("The character has graphical representation"); else printf("The character isn’t having graphical representation"); if(isgraph(c)) ... Read More

948 Views
strlen()The function strlen() is a predefined function in C language. This is declared in “string.h” header file. It is used to get the length of array or string.Here is the syntax of strlen() in C language, size_t strlen(const char *string);Here, string − The string whose length is to be calculated.Here is an example of strlen() in C language, Example Live Demo#include #include int main () { char s1[10] = "Hello"; int len ; len = strlen(s1); printf("Length of string s1 : %d", len ); return 0; }OutputLength of string s1 : 10In the above ... Read More

2K+ Views
The function isupper() is used to check that the character is uppercase or not. It returns non-zero value if successful otherwise, return zero. It is declared in “ctype.h” header file.Here is the syntax of isupper() in C language, int isupper(int character);Here, character − The character which is to be checked.Here is an example of isupper() in C language, Example Live Demo#include #include int main() { char val1 = 's'; char val2 = 'S'; if(isupper(val1)) printf("The character is uppercase"); else printf("The character is not uppercase"); if(isupper(val2)) printf("The character is uppercase"); else printf("The ... Read More

9K+ Views
The function isalnum() is used to check that the character is alphanumeric or not. It returns non-zero value, if the character is alphanumeric means letter or number otherwise, returns zero. It is declared in “ctype.h” header file.Here is the syntax of isalnum() in C language, int isalnum(int character);Here, character − The character which is to be checked.Here is an example of isalnum() in C language, Example Live Demo#include #include int main() { char val1 = 's'; char val2 = '8'; char val3 = '$'; if(isalnum(val1)) printf("The character is alphanumeric"); else printf("The character is not ... Read More

7K+ Views
Here is an example to print contents of a file in C language, Let’s say we have “new.txt” file with the following content.0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoNow, let us see the example.Example#include #include void main() { FILE *f; char s; clrscr(); f=fopen("new.txt", "r"); while((s=fgetc(f))!=EOF) { printf("%c", s); } fclose(f); getch(); }Output0, hell!o 1, hello! 2, gfdtrhtrhrt 3, demoIn the above program, we have a text file “new.txt”. A file pointer is used to open and read the file. It is displaying the content of file.FILE *f; ... Read More

721 Views
The function fopen() opens the file pointed by pointer and read or write the file. In the write mode, “w” is used and in the read mode, “r” is used.When a file exists in the directory, it treats as a new empty file and override the content of file by new data.Here is the syntax of fopen() in C langauge, FILE *fopen(const char *filename, const char *access_mode)Here, filename − The name of file which is to be opened.acess_mode − The mode to access the file like read or write mode.Here is an example of fopen() in C language, Let’s say ... Read More