Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 968 of 2547
Add two unsigned numbers using bits in C++.
In this problem, we are given two unsigned numbers, and we need to add them using bits in C. Bits are binary digits that can be either 0 or 1. Unsigned numbers are positive numbers represented by these bits. To add two unsigned numbers, we add their bits one by one using binary addition rules. Syntax unsigned int addBits(unsigned int a, unsigned int b); Binary Addition Rules Binary addition works like decimal addition, but with simpler rules − 0 + 0 = 0 0 ...
Read MoreAdd two numbers represented by two arrays in C Program
A number represented by an array is stored in such a form that each digit of the number is represented by an element of the array. For example − Number 234 in array is {2, 3, 4} To add two such numbers we will first add digits from the least significant position and if the sum is greater than 9, we propagate the carry. We continue this process for consecutive digits until all digits are processed. Syntax void addArrays(int arr1[], int arr2[], int size1, int size2, int result[]); Algorithm To ...
Read MoreC/C++ Tricky Programs
Here are 10 tricky C programming challenges that will test your understanding of language fundamentals and creative problem-solving techniques. 1. Program to Print Double Quotes in C Printing double quotes in C requires escape sequences since quotes are used to delimit string literals. We use the backslash escape sequence " to print quotes − #include int main() { printf(""Tutorials Point ""); return 0; } "Tutorials Point " 2. Print Numbers 1 to 10 Without Loops or Goto When loops and ...
Read MoreC/C++ Program for Greedy Algorithm to find Minimum number of Coins
A greedy algorithm is an algorithmic approach used to find an optimal solution for the given problem. Greedy algorithm works by finding locally optimal solutions (optimal solution for a part of the problem) of each part so that the global optimal solution can be found. In this problem, we will use a greedy algorithm to find the minimum number of coins/notes that could makeup to the given sum. For this we will take under consideration all the valid coins or notes i.e. denominations of { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000 }. We need to ...
Read MoreDifference between Compile Time Errors and Runtime Errors in C Program
Errors in C programming are interruptions that prevent code from executing successfully. Based on when they occur, errors can be classified into two main categories: compile time errors and runtime errors. Syntax // Compile Time Error Example int x = 10 // Missing semicolon // Runtime Error Example int result = 10 / 0; // Division by zero Comparison Table Sr. No. Key Compile Time Errors Runtime Errors 1 Definition Errors related to syntax or semantics detected during compilation Errors that occur ...
Read MorePrint matrix in zag-zag fashion in C Programming.
In C programming, printing a matrix in zig-zag fashion means traversing the matrix diagonally while alternating the direction of traversal. This creates a zig-zag pattern where elements are visited along diagonals, first from top-left to bottom-right, then from bottom-right to top-left, and so on. 10 20 30 40 50 ...
Read MorePrint matrix in snake pattern from the last column in C Programming.
In C, printing a matrix in snake pattern from the last column means traversing the matrix row by row, alternating the direction of column traversal. For odd-numbered rows (index 0, 2, 4...), we print from right to left, and for even-numbered rows (index 1, 3, 5...), we print from left to right. Matrix Snake Pattern from Last Column 10 20 30 40 ...
Read MorePrint matrix in snake pattern in C Programming.
In C programming, printing a matrix in snake pattern means traversing the matrix row by row where even-indexed rows are printed from left to right and odd-indexed rows are printed from right to left. This creates a snake-like zigzag pattern through the matrix elements. ...
Read MorePrint shortest path to print a string on screen in C Program.
Given a string, the program must display the shortest path which will print the string over the screen using that shortest path. The alphabets are arranged on a virtual keyboard in a 5x5 grid format. The keyboard layout is − A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Syntax void printpath(char str[]); Algorithm The approach stores characters in a matrix and calculates the shortest path by − If row difference ...
Read MorePrint sorted distinct elements of array in C language
Given an array of integer elements, the task is to remove duplicate values and print the distinct elements in sorted order. For example, given an array that stores values {4, 6, 5, 3, 4, 5, 2, 8, 7, 0}, we need to identify unique elements and sort them. The final result should be {0, 2, 3, 4, 5, 6, 7, 8}. Original Array: 4 6 ...
Read More