- 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 34484 Articles for Programming
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
893 Views
Here is the code to emulate N dice roller. This can be done by generating random number between 1-6.AlgorithmBegin Declare n Read n For i = 0 to n-1 do Generate sequence with rand() mod 6 + 1 Print the sequence Done EndExample Code#include using namespace std; int main(int argc, char **argv) { cout > n; cout
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
3K+ Views
Here we will see how to generate hollow pyramid and diamond patterns using C. We can generate solid Pyramid patterns very easily. To make it hollow, we have to add some few tricks.Hollow PyramidFor the pyramid at the first line it will print one star, and at the last line it will print n number of stars. For other lines it will print exactly two stars at the start and end of the line, and there will be some blank spaces between these two starts.Example Code#include int main() { int n, i, j; printf("Enter number of lines: ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
3K+ Views
In this section we will see how to make a digital clock using C. To work with time we can use the time.h header file. This header file has some function signatures that are used to handle date and time related issues.The four important components of time.h is like belowsize_t This size_t is basically the unsigned integral type. This is the result of sizeof().clock_t This is used to store the processor timetime_t This is used to store calendar timestruct tm This is a structure. It helps to hold the entire date and time.Example Code#include #include int main() { ... Read More
![Nancy Den](https://www.tutorialspoint.com/assets/profiles/13557/profile/60_88439-1512714529.jpg)
211 Views
The multiply-with-carry method is a variant of the add-with-carry generator introduced by Marsaglia and Zaman (1991). The main advantages of this method are that it invokes simple computer integer arithmetic and leads to very fast generation of sequences of random numbers with immense periods, ranging from around 260 to 22000000.In MWC base b is chosen to equal to the computer word size and multiplier a and lag r determine the modulus p = abr−1. Here, a is chosen so the modulus is prime and the multiplier has long period.AlgorithmBegin Declare maximum _sequence _elements, b, r, c[maximum _sequence ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
The PGM is the Portable Gray Map. If we want to store a 2d array in C as images in PNG, JPEG, or any other image format, we have to do lots of work to encode the data in some specified format before writing into a file.The Netpbm format gives an easy and portable solution. The Netpbm is an open source package of graphics program and it is used basically in linux or Unix platform. It also works under Microsoft Windows systems.Each file starts with a two-byte magic number. This magic number is used to identify the type of the ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
118 Views
Naor-Reingold Pseudo Random Function is another method of generating random numbers.Moni Naor and Omer Reingold described efficient constructions for various cryptographic primitives in private key as well as public-key cryptography, in 1997. Let p and l be prime numbers with l |p−1. Select an element g ε Fp* of multiplicative order l. Then for each n-dimensional vector a = (a0, a1, ..., an).They define the functionfa(x)=ga0.a1x1a2x2…..anxn ε Fpwhere x = x1 … xn is the bit representation of integer x, 0 ≤ x ≤ 2 n−1This function can be used as the basis of many cryptographic schemes including symmetric encryption, ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
7K+ Views
In this program we will see how to validate an IP address using C. The IPv4 addresses are represented in dot-decimal notation. There are four decimal numbers (all are ranging from 0 to 255). These four numbers are separated by three dots.An example of a valid IP is: 192.168.4.1To validate the IP address we should follow these stepsTokenize the string (IP address) using the dot “.” delimiterIf the sub strings are containing any non-numeric character, then return falseIf the number in each token is not in range 0 to 255, then return falseIf there are exactly three dots and four ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
568 Views
In this article we will see how we can print some characters without using any kind of format specifiers. The format specifiers in C are %d, %f, %c etc.These are used to print characters and numbers in C using the printf() function.Here we will see another way to print characters without using %c format specifier. This can be done by putting ASCII values directly in hexadecimal form.Example Code#include main () { printf("\x41 "); //41 is ASCII of A in Hex printf("\x52 "); //41 is ASCII of A in Hex printf("\x69 ... Read More
![Krantik Chavan](https://www.tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
355 Views
Park-Miller Random Number Generation Algorithm is another method of generating random numbers.A general formula of a random number generator (RNG) of this type is: X_{k+1} = g X(k) mod nWhere the modulus n is a prime number or a power of a prime number, the multiplier g is an element of high multiplicative order modulo n, and the seed X0 is coprime to n.AlgorithmBegin Declare variables n, a, b, c and seed Read variables n, a, b, c and seed Uniform() Declare variable hi, lo, t hi=seed divided by b lo = seed - ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
In this section we will see how to write a program in C that cannot be terminated by the Ctrl + C key.The Ctrl + C generates the keyboard interrupt, and it stops the execution of the current process. Here when we will press the Ctrl + C key, it will print a message then continues the execution. To use this functionality, we will use the signal handling technique in C. When the Ctrl + C is pressed it generates SIGINT signal. There are some other signals and their functionalities in the following list.SignalDescriptionSIGABRTIndicates Abnormal terminationSIGFPE Indicates floating point exceptionSIGILL Indicates invalid ... Read More