Posts

Showing posts with the label C

Usage of Common “Header files” in C programming

  Each of these header files serves a specific purpose in a C program: stdio.h : This header file stands for "standard input-output header" and provides functions for input and output operations such as  printf()  and  scanf() . stdlib.h : It stands for "standard library" and provides functions such as memory allocation ( malloc() ,  calloc() ,  free() ), random number generation ( rand() ,  srand() ), and other utility functions. string.h : This header file provides functions for manipulating strings such as  strcpy() ,  strcat() ,  strlen() , etc. conio.h : This header file provides functions mainly for console input and output operations in DOS and Windows environments. Functions like  getch()  and  clrscr()  are included in this header file. However, note that it's not a standard C library and is often not available in many modern compilers or platforms. time.h : This header file provides functions to work with da...

Easiest way to print `int 128 bit` or`unsigned int 128 bit`

Image
  To print `__int128`, you must use `__int128_t`data type. Because there is no data type named __int128. At least I didn’t find any till now. And You must use “typecasting” every time in assigning value and outputting values. you must use format specifier `%lld` for `__int128_t` and `%llu`for `__uint128_t`. in C++, `std::cout`printing… you must use `static_cast <long long> (var_name)` Code: # include <iostream> int main () { // int 128 bit __int128_t var = ( long long ) -23542342345435 ; // unsigned int 128 bit __uint128_t var2 = ( long long ) 64324234234234 ; // printing in c++ std::cout << "int 128 bit: " << static_cast < long long >(var) << std::endl; // printing in c printf ( "int 128 bit: %lld\n" , ( long long )var); // printing in c++ std::cout << "unsinged int 128 bit: " << static_cast < long long >(var2) << std::endl; // printing in c printf ( "unsinged int 128 bi...

Bitwise Operators in C/C++

Image
  Bitwise Operators in C/C++ In C, the following 6 operators are bitwise operators (also known as bit operators as they work at the bit-level). They are used to perform bitwise operations in C. The & (bitwise AND) in C or C++ takes two numbers as operands and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1. The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1. The ^ (bitwise XOR) in C or C++ takes two numbers as operands and does XOR on every bit of two numbers. The result of XOR is 1 if the two bits are different. The << (left shift) in C or C++ takes two numbers, the left shifts the bits of the first operand, and the second operand decides the number of places to shift. The >> (right shift) in C or C++ takes two numbers, right shifts the bits of the first operand, and the second operand decides the number of places to shift. The ~...

Array of Strings in C programming

Image
Array of Strings in C programming Size of an array: T he size of the  ss  array is 32 because it's an array of pointers to characters (i.e., strings). In C, the size of a pointer is typically 4 or 8 bytes, depending on the architecture (32-bit or 64-bit). I n your case, it seems like you're running this code on a 64-bit system, where the size of a pointer is 8 bytes. The  ss  array has 3 elements, each of which is a pointer to a string. So, the total size of the  ss  array is 4 *  8 = 32 bytes. This is why  sizeof(ss)  is32....

Mastering the Fundamentals of C++ Programming

**Title: Mastering the Fundamentals of C++ Programming** C++ is a powerful and versatile programming language that has stood the test of time. Whether you're a beginner venturing into the world of coding or an experienced developer looking to expand your skill set, understanding the fundamentals of C++ is a valuable investment in your programming journey. In this comprehensive guide, we'll explore the core concepts of C++, its syntax, and practical applications. By the end, you'll have a solid grasp of C++ programming essentials. **Why Learn C++?** Before we dive into the fundamentals, let's understand why C++ remains relevant and important: 1. **High Performance:** C++ is known for its efficiency and performance, making it an excellent choice for system-level programming, game development, and resource-intensive applications. 2. **Versatility:** C++ can be used for various applications, including desktop software, embedded systems, and game engines. It offers low-level...

Bitwise Operators in C/C++

Image
Bitwise Operators in C/C++ In C, the following 6 operators are bitwise operators (also known as bit operators as they work at the bit-level). They are used to perform bitwise operations in C. The & (bitwise AND) in C or C++ takes two numbers as operands and does AND on every bit of two numbers. The result of AND is 1 only if both bits are 1. The | (bitwise OR) in C or C++ takes two numbers as operands and does OR on every bit of two numbers. The result of OR is 1 if any of the two bits is 1. The ^ (bitwise XOR) in C or C++ takes two numbers as operands and does XOR on every bit of two numbers. The result of XOR is 1 if the two bits are different. The << (left shift) in C or C++ takes two numbers, the left shifts the bits of the first operand, and the second operand decides the number of places to shift. The >> (right shift) in C or C++ takes two numbers, right shifts the bits of the first operand, and the second operand decides the number of places to shift. The ~ (bit...

Way Too Long Words - Codeforces problem solution

 Way Too Long Words - Codeforces problem solution  A. Way Too Long Words Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome. Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation. This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes. Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n". You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes. Input...

Way Too Long Words - Codeforces problem solution

Way Too Long Words - Codeforces problem solution   A. Way Too Long Words Sometimes some words like " localization " or " internationalization " are so long that writing them many times in one text is quite tiresome. Let's consider a word  too long , if its length is  strictly more  than  10  characters. All too long words should be replaced with a special abbreviation. This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes. Thus, " localization " will be spelt as " l10n ", and " internationalization » will be spelt as " i18n ". You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo ...

Popular posts from this blog

12 Best Websites to Practice Coding for Beginners

Using Generic in TypeScript about types in the Code

Codeforces Round #822 (Div.2) Editorial