Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include <stdio.h>
#include <math.h>
#include <chplot.h>
#define N 10         /*for 5 step size*/
#define A 10.0      /*constant value of shear stress in kgf/mm^2*/


double calculate_thickness(double r);

int main(){
    
    int  x0=100,xf=500,xstep=50;  
    double i,j,r,w,E;
    double P[N],t[N];

    printf("Enter the value of plate width, w in mm: ");      /*plate width in mm*/
    scanf("%lf",&w);
    
    printf("*Enter 1 for radiography inspection\n");         /*selection of inspection*/
    printf("*Enter 2 for no radiography inspection\n");
    printf("Enter your type of inspection: ");
    scanf("%lf",&r);
    
    printf("  Tensile load,P(kN)   |    thickness,t(mm) \n");   /*for table uses*/
    printf("--------------------------------------------\n");
   
    if(r == 1){
        E=0.9;  /*efficiency when radiography inspection 90%*/
        for (i=0; i<n;>            P[i]=x0+i*xstep;
            t[i]=P[i]/(w*(E*A));    /*equation to find the thickness of welding specimen*/
            printf("     %6.f            |     %6.3f     \n",P[i],t[i]);
        }
    }
    else if(r ==2){
        E=0.65;  /*efficiency when no radiography inspection 65%*/
        for (j=0; j<n;>            P[j]=x0+j*xstep;
            t[j]=P[j]/(w*(E*A));    /*equation to find the thickness of welding specimen*/
            printf("     %6.f            |     %6.3f     \n",P[j],t[j]);
        }
    }
    else{
        printf("Error!\n");
    }
    return 0;
}
double calculate_thickness(double r)
{
    int i,j,r;
    double t[N],P[N];
    
    if (r == 1){
        scanf("%lf",&P[i]);
        scanf("%lf",&t[i]);
    }
    else if (r == 2){
        scanf("%lf",&P[j]);
        scanf("%lf",&t[j]);
    }
    else{
        printf("Error!");
    }
    plotxy(P, t, N, "Acceleration Plot","Tensile load(kN)", "thickness(mm)");
    return 0;
}


What I have tried:

I already try to used another function and check the note what I have learn in array rules. I have no idea why the graph is not come out. The error said that "ERROR: computational array type qualifier applied to a scalar variable
ERROR: function cannot return C array, it can only return computational array"
Posted
Updated 23-May-16 2:38am
v2
Comments
Patrice T 21-May-16 16:32pm    
The error message should also include the position (line number in source code)
Can you show it with a comment in code ?

At first and most important
C++
double calculate_thickness(double r) // here comes an r
{
    int i,j,r; //here is the OTHER r !!!!!
    double t[N],P[N];
    
    if (r == 1){


Your call of the plotxy is totally buggy. You must initialize ALL N-fields of the array like

C++
double t[N] = {0};
and make N as little as needed.

Tip: Learn to use the debugger and make outputs on the console!!!
 
Share this answer
 
I fear that the fact that you don't call the routine calculate_thickness that do the plot can be one of your problems.
Using uninitialized variables will not help either.
defining only 1 point in the plot routine may also be a problem.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900