Maniruzzaman Akash's Blog

Maniruzzaman Akash, A programmer, A web programmer, a helpful person to share knowledge and everything..

  • Home
  • Programming
    • C Programming
    • Java Programming
    • C++ Programming
    • C# Programming
    • Python Programming
    • Data Structure
  • Web
    • HTML
    • CSS
    • Javascript
    • PHP
    • AJAX
    • XML
  • FrameWork
    • Bootstrap(CSS)
    • Laravel 5(PHP)
  • Database
    • MySQL
    • Oracle
    • SQL Server
  • Android
    • Android Development
  • Mathematics
    • Numerical Methods
  • Others
    • My Articles
    • Download Ebooks
    • Mathematics
    • Difference Between
  • Contact
C Programming MatLab Code Simulation and Modeling

Residue Method's Code in C and MatLab | Congruential Method Code

Wednesday, October 11, 2017 By Maniruzzaman Akash 4 Comments
Problem:

Residue Method's Code in C and MatLab | Congruential Method Code


Details:

We need the generate random numbers using Residue method. How do we generate that random number?



Solution:


Random Number generation code in C using Residue Method:


/**
    Code    : Residue/Congruential Method in C
    Author  : Maniruzzaman Akash<manirujjamanakash@gmail.com>
**/

#include<stdio.h>
int main(){
    //r(i) = (ar(i-1) + b ) modulo m
    int random[1000], maxLimit, i, n;
    printf("First Random Number or seed : ");
    scanf("%d", &random[0]);

    printf("What is the maximum limit : ");
    scanf("%d", &maxLimit);

    printf("How many eandom Number you want to generate : ");
    scanf("%d", &n);

    int a = 19, b = 1;

    printf("\nRandoms are : ");
    for(i = 1; i <= n; i++){
        //
        random[i] = ( a * random[i - 1] + b ) % maxLimit;
        printf("%d ", random[i]);
    }
    printf("\n");
}



Random Number generation code in Matlab using Residue Method:

a=input('Please Enter the value of a : ');
b=input('Please Enter the value of b : ');
m=input('Please Enter the value of m : ');
r=input('Please Enter the value of seed or r : ');


totalNumber = input('Number of Random Numbers want to generate : ');
R = zeros();

for i = 1:totalNumber
    r = mod(a*r +b, m);
    R(i) = r;
    fprintf('%4.0f ', R(i));
end
fprintf('\n');


Formula/Algorithm of residue

    //r(i) = (ar(i-1) + b ) modulo m

Simple One Line Instruction, nothing to say here.



Demo Screenshot of Residue Method code and output in C

Residue Method's Code in C and MatLab | Congruential Method Code


Tags:
Residue Method's Code in C and MatLab | Congruential Method Code, Residue Method, Congruential Method, Residue Method full code in C programming, Residue Method full Code in MatLab
C Programming
Share:

Maniruzzaman Akash
Maniruzzaman Akash, an enthusiastic programmer, a web developer

Related Articles


4 comments:

  1. Monica phillipaApril 28, 2022 at 6:06 PM

    This post of RESIDUE METHOD'S CODE IN C AND MATLAB | CONGRUENTIAL METHOD CODE, which is so supreme and authentic for all but there are also very beneficial and desiring web 2.0 backlinks to getting from them in all over the USA

    ReplyDelete
    Replies
      Reply
  2. AnonymousAugust 25, 2022 at 6:02 PM

    Genex Logistics, India's 3PL Company offers a wide range of logistical solutions to Contract Logistics, 3PL Space, Freight Forwarding, Shipping, Project Logistics, Reverse Logistics Solutions and Transportation. Whatever your company's requirements may be the innovative strategies we employ to manage logistics will help you grow. Genex Logistics provides a range of services to its clients. This includes distribution warehouses, distributionnetworks, which are unambiguous and industry-leading in their logistics Design and Inventory Management and Freight Forwarding plans which are tech-driven and based on credibility research. More information on Logistics Cost Meaning and importance are available on Genex Logistics'.

    ReplyDelete
    Replies
      Reply
  3. AnonymousOctober 16, 2023 at 6:09 PM

    いつものように、この作品はまた別の魅力的な視点を提供してくれました。 たまたまですが、私は(core ball)をよくプレイしています。 中心で回転する「コアボール」を狙う、忍耐力と器用さが求められる楽しいチャレンジは、信じられないほど魅力的です。

    ReplyDelete
    Replies
      Reply
  4. Road BridgeOctober 12, 2024 at 12:20 AM

    demolition expert in Edmonton ensures the safe and precise removal of structures, whether residential or commercial. Their knowledge of local regulations and best practices guarantees efficient, responsible demolition.

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Newer Post Older Post Home
Subscribe to: Post Comments ( Atom )

Popular Posts

  • Numerical Methods 20 Multiple Choice Questions and Answers
  • Consider a hypothetical 32-bit microprocessor having 32-bit instructions: Solutions
  • List and briefly define two approaches to dealing with multiple interrupts
  • The hypothetical machine has two I/O instructions: 0011= Load AC fro I/O 0111= Store AC to I/O Solutions
  • What are the characteristics of Digital IC's?-Solution
  • Mid Square Method Code implementation in C and MatLab
  • List and briefly define the possible states that define an instruction execution
  • BFS, DFS, DLS in Tree implementation in C
  • Download Laravel Offline Documentation as HTML
  • Simpson's 1/3 Code in Matlab

Category

Advanced PHP Android Developement Articles Artificial Intelligenece Blogger Tips Blogging Career Bootstrap Offline Documentation Bootstrap Templates C Programming Computer Architecture Data Structure Difference Between Download Documentation Download Ebook Download Free Blog Template Earning Money Electrical Electronics Guest Posts HTML Java Programming Laravel Laravel Bangla Tutorial MatLab Code My Videos MySQL Database Numerical Methods Offline Documentation Recent Topics Simulation and Modeling Unity Game Development Web Design Web Development

LIKE ME ON FACEBOOK

TAGS

  • Advanced PHP (3)
  • Android Developement (5)
  • Articles (6)
  • Artificial Intelligenece (3)
  • Blogger Tips (5)
  • Blogging Career (1)
  • Bootstrap Offline Documentation (1)
  • Bootstrap Templates (1)
  • C Programming (14)
  • Computer Architecture (5)
  • Data Structure (11)
  • Difference Between (1)
  • Download Documentation (2)
  • Download Ebook (3)
  • Download Free Blog Template (2)
  • Earning Money (1)
  • Electrical Electronics (1)
  • Guest Posts (1)
  • HTML (4)
  • Java Programming (2)
  • Laravel (3)
  • Laravel Bangla Tutorial (1)
  • MatLab Code (2)
  • My Videos (3)
  • MySQL Database (7)
  • Numerical Methods (9)
  • Offline Documentation (1)
  • Recent Topics (1)
  • Simulation and Modeling (2)
  • Unity Game Development (3)
  • Web Design (3)
  • Web Development (1)

Join Google+

Maniruzzaman Akash
View my complete profile

Join With Me

Site Visitors

Best Sites For a programmer

  • URI Online Judge Solution By Me
  • StackOverFlow
  • W3 School
  • Git Hub - Store your Every Document

Popular Posts

  • What are the characteristics of Digital IC's?-Solution
  • How to import Excel,CSV file in Laravel And insert data in database
  • Numerical Methods 20 Multiple Choice Questions and Answers
  • What is Blue Whale Game ? Why people suicide?
  • List and briefly define two approaches to dealing with multiple interrupts
  • Mid Square Method Code implementation in C and MatLab
  • The hypothetical machine has two I/O instructions: 0011= Load AC fro I/O 0111= Store AC to I/O Solutions
  • Depth First Search DFS code using Binary Tree in C language
  • Simpson's 1/3 Code in Matlab
  • Consider a hypothetical 32-bit microprocessor having 32-bit instructions: Solutions

Earn Money From Your site

Translate To your language

Categories

Advanced PHP (3) Android Developement (5) Articles (6) Artificial Intelligenece (3) Blogger Tips (5) Blogging Career (1) Bootstrap Offline Documentation (1) Bootstrap Templates (1) C Programming (14) Computer Architecture (5) Data Structure (11) Difference Between (1) Download Documentation (2) Download Ebook (3) Download Free Blog Template (2) Earning Money (1) Electrical Electronics (1) Guest Posts (1) HTML (4) Java Programming (2) Laravel (3) Laravel Bangla Tutorial (1) MatLab Code (2) My Videos (3) MySQL Database (7) Numerical Methods (9) Offline Documentation (1) Recent Topics (1) Simulation and Modeling (2) Unity Game Development (3) Web Design (3) Web Development (1)

Subscribe To This Site To Get Latest Article On Programming or web

Posts
Atom
Posts
Comments
Atom
Comments
© 2016 Maniruzzaman Akash's Blog | All rights reserved
Developed By Maniruzzaman Akash Created By Responsive Blogger Templates | Distributed By Gooyaabi Templates