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 Numerical Methods Simulation and Modeling

Mid Square Method Code implementation in C and MatLab

Wednesday, October 11, 2017 By Maniruzzaman Akash 7 Comments

Mid Square Method Code implementation in C and MatLab:

Problem:

Mid square method, mid square random number generator Code in MatLab and C or C++.



Mid Square Method Code implementation in C and MatLab

Solution:

Mid Square Random Number Generator Code in C:

/**
    Code    :: Mid Square Random Number Generator
    Author  :: Maniruzzaman Akash <manirujjamanakash@gmail.com>
*/

#include<stdio.h>
int main()
{
    long int seed = 6897; //take any 4 digit Number without trailing 00
    int i, n, random;
    printf("How many number you want to generate : ");
    scanf("%d", &n);

    printf("Random Numbers are : ");

    for(i = 0; i < n; i++)
    {
        seed = seed * seed;
        seed = seed / 100;       //Take the dividend
        seed = seed % 10000;    // Take the reminder
        random = seed;
        printf("%d ", random);
    }

    printf("\n");
    return 0;
}


Output of the Mid Square Random Number Generator code in C:


Mid Square Random Number Code in Matlab:

%% Problem : Random Number Generator ---> Mid Square Method %%
%  Author  : Maniruzzaman Akash

totalNumber = input('Number of Random Numbers want to generate : ');
choose = input('Enter the seed : ');
disp('Total Random Numbers are : ');
for i = 1:totalNumber
    random = choose ^ 2;
    random = random / 100; % Find the dividend
    random = rem(random, 10000); % Get the reminder;
    choose = random;
    fprintf('%.2f ', random);
end
fprintf('\n');



Procedure of Mid Square Method Random Number Generator:


  1. Take the first seed or first random number.
  2. Square it.
  3. Take the middle from the 8 digits square value
  4. divide it by 100 first then
  5. take the reminder of 10000 of that value again
  6. Finally result will present in the seed or in random.




Tags:

Numerical Methods, Simulation and Modeling, C Programming, MatLab Code, Mid Square Method Code, Midsquare code implementation,



C Programming
Share:

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

Related Articles


7 comments:

  1. Pale KingMarch 26, 2020 at 5:19 PM

    I really appreciate this article, and please may I ask you to translate to English another one, ok? You will literally save my life! Currently I have faced a lot of problems with my programming dissertation as it consists of two parts, technical and preface writing. As a tech person I can't write anything at all. So I am trying to get help from https://findmywriters.com/top-quality-essay-writing-services/ this blog but I would like to ask you, have you ever faced such a requirement?

    ReplyDelete
    Replies
    1. AnonymousMarch 13, 2022 at 7:38 AM

      Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download Now

      >>>>> Download Full

      Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download LINK

      >>>>> Download Now

      Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download Full

      >>>>> Download LINK Ln

      Delete
      Replies
        Reply
    2. Reply
  2. AnonymousAugust 18, 2020 at 12:53 PM

    If we Don't define how many numbers we want to generate & let the program continue until the output is 0 or a previous value is repeated , then how should we write this condition?

    ReplyDelete
    Replies
      Reply
  3. sherazabbasiJune 12, 2021 at 7:12 PM

    Daisy Limousine provides the best black car service in the tri-state area. We can provide limo service or airport service in New Jersey, New York, Rhode Island, Massachusetts, Pennsylvania, and Connecticut. Our on-time ground transportation service will drive you pretty much from A to B anywhere in the North East of America. Give us a call or book a ride online at your convenience
    why not check here

    ReplyDelete
    Replies
      Reply
  4. sherazabbasiJuly 20, 2021 at 3:22 PM

    I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    Email Extractor Software

    ReplyDelete
    Replies
      Reply
  5. Ross KelleySeptember 16, 2021 at 5:03 PM

    It was a very good post indeed. I thoroughly enjoyed reading it in my lunch time. Will surely come and visit this blog more often. Thanks for sharing. indická žádost o vízum

    ReplyDelete
    Replies
      Reply
  6. AnonymousMarch 13, 2022 at 7:38 AM

    Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download Now

    >>>>> Download Full

    Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download LINK

    >>>>> Download Now

    Mid Square Method Code Implementation In C And Matlab - Maniruzzaman Akash'S Blog >>>>> Download Full

    >>>>> Download LINK

    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
  • The hypothetical machine has two I/O instructions: 0011= Load AC fro I/O 0111= Store AC to I/O Solutions
  • Consider a hypothetical 32-bit microprocessor having 32-bit instructions: Solutions
  • How to import Excel,CSV file in Laravel And insert data in database
  • What is Blue Whale Game ? Why people suicide?
  • List and briefly define the possible states that define an instruction execution
  • List and briefly define two approaches to dealing with multiple interrupts
  • ফিফা ওয়ার্ল্ড কাপ ২০১৮ শিডিউল এবং সমস্ত আপডেট- FIFA World Cup 2018 - Bangladesh Time Schedule
  • BFS, DFS, DLS in Tree implementation in C
  • Numerical Methods 20 Multiple Choice Questions and Answers

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