Print Numbers from 1 to 100 Without Using Loop in C

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:12:19

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

C++ Program to Find Factorial of Large Numbers

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:09:05

2K+ Views

A factorial of a number defines the non-negative integer say n that calculate the product of a number by every positive integer until it reaches 1. The symbol of factorial is (!). Mathematically, it is represented by: n! = n x (n-1) x (n-2) x ... x 1 For eg. factorial of an integer 30! = 265252859812191058636308480000000. 30! = 30x29x28x27x26x25x24x23x22x21x20x19x18x17x16x15x14x13x12x11x10x9x8x7x6x5x4x3x2x1 A non-negative integer is defined by any whole number that is 0 or positive (not a fraction or decimal). What is Large Number? In context of calculating the factorial number, the large number denotes the n value ... Read More

Convert Single Char to Int in C++

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:07:05

801 Views

In C++, converting a single character into an integer is possible using various techniques like STL functions say atoi() and stoi(). Also, you can solve this with the help of ASCII value or stringstream function. Converting Single Char into Int Here, we have list down of four approaches that help to convert the single character into an integer form as follows: Using ASCII Subtraction Using stoi() Function Using atoi() Function Using stringstream Function Using ASCII Subtraction ASCII subtraction converts a digit character to an integer by subtracting '0' from it. This works because digit characters are stored sequentially ... Read More

Find Fibonacci Numbers Using Iteration in C++

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:06:34

9K+ Views

The term Fibonacci numbers is used in mathematics, which calculates the sum of two preceding numbers that starts from 0 and 1 and continues till based on the given number say num. Mathemathematically, it is represented by: Fn = Fn-1 + Fn-2 Let us take an example to understand the above formula based on fibonacci numbers. F0 = 0 F1 = 1 F2 = F1 + F0 = 1 + 0 = 1 F3 = F2 + F1 = 1 + 1 = 2 F4 = F3 + F2 = 2 + 1 = 3 ... Read More

Character Arithmetic in C

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:06:05

6K+ Views

In C, character arithmetic is defined by char data type. This is used to implement arithmetic operations like addition and subtraction on characters in C language. It is used to manipulate the strings. When the characters are used with the arithmetic operations, it converts them into integer value automatically i.e. ASCII value of characters. Understanding Characters Represention To understand the character represented using char data type then learn the ASCII value (integer) of each character. Some values are provided for the references such as, 'A' has an ASCII value of 65 'B' has an ASCII value of 66 'a' has ... Read More

What are Wild Pointers in C/C++

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:05:33

3K+ Views

In C/C++, a wild pointer is a type of pointer that has not been initialized to a valid memory address. It points to memory that has been deallocated and is called a dangling pointer. The pointer behaves like a wild pointer when it is declared but not initialized. That is why, they point to random memory location. Syntax The basic syntax of initializing wild pointer in C/C++: int *ptr; Example of Wild Pointer In this example, we create a pointer arr that doesn't assign it any memory. Then, it tries to print 5 values from it using a loop. ... Read More

Print Hello World without Using Any Header File in C

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:02:10

1K+ Views

In C/C++, we use the header files for accessing functions such as int, char, string, etc. The printf() function of C is also a built-in function that is declared in the "stdio.h" header file and it is used to print any kind of data on the console. C to Print "Hello World" without Header Files The Hello World is the given string that is used in the printf() to get the output. Make sure you don't have any headers to print the result. So, use an argument like (const char *text, ...) that solves the problem. Syntax Below is the ... Read More

Implement Your Own sizeof Operator Using C++

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:00:20

978 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

What Does is Operator Do in Python

Disha Verma
Updated on 21-Apr-2025 16:34:55

3K+ Views

The "is" operator in Python is an identity operator. This operator checks whether two variables refer to the same object in memory. It returns boolean values as a result. Each object in the computer's memory is assigned a unique identification number (id) by the Python interpreter. Identity operators check if the id() of two objects is the same. The 'is' operator returns false if id() values are different and true if they are the same. Syntax of Python (is) Operator The "is" operator follows the following syntax in Python: variable1 is variable2 The "is" operator ... Read More

Difference Between 'and' and 'OR' Operators in Python

Disha Verma
Updated on 21-Apr-2025 16:33:43

2K+ Views

The OR and (|) are logical operators in Python. The difference between these two is that OR is a Logical OR operator, and | is a Bitwise OR Operator. Both operators are used to perform different operations. In this article, we will explore the behavior of these operators and their differences. OR Operator in Python The OR operator in Python returns true if one of the operands is true and false if both operands are false. This operator needs two values or operands to perform the operation and return the result. OR Operator Example The following ... Read More

Advertisements