Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6751121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:53:22+00:00 2026-05-26T12:53:22+00:00

Hi here is my problem i am able to input values for my matrix

  • 0

Hi here is my problem i am able to input values for my matrix as such

for(i=0;i<n;i++)
{
for(j=0;j<n;j++){
scanf("%d",&a[i][j]);

how ever this is very tedious for matrices of a large order and i cant get the matrix to work with pointers and the rand function

for(i=0;i<n;i++)
    {
    for(j=0;j<n;j++){
&a[i][j] = -1 + rand() * (double)(2) / RAND_MAX;

this code compiles but results in errors also this with out the & operator compiles and gives me incorrect results as well

a[i][j] = -1 + rand() * (double)(2) / RAND_MAX;

what am i missing for the pointers to work as such?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:53:23+00:00Added an answer on May 26, 2026 at 12:53 pm

    Apparently a is an array of int (you are using "%d" to input values with scanf).

    The expression you use generates doubles (ranging from -1 to 1) that when converted to int result in 0. I guess that’s what you see in a.

    Make a an array of doubles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I think this is a common problem... yet i have not been able to
Here is my problem... I don't understand why this isn't working for me :)
I'm solving a problem mentioned here I was able to do custom format of
Answer Summary: Solved this problem using Jon Skeet's answer below. Here is the finished
Here's the problem, in abstract terms: i have three input fields (A, B, C).
What is the problem here? (Besides having redundant code). $.getJSON works as expected. However
I have a problem here. My Zend_Forms do not render in view script. Via
I've got a problem here with an MSI deployment that I'm working on (using
Just a small SVN problem here. I setup my own SVN server Setting up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.