Am i right How is my code ??
If error then highlighted
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include<iostream>
#include<conio.h>
using namespace std;
float temp,arr[10][6],answer[6];
int faheem;
void readdata()
{
short i,j,k=8,I=20;
goto xy;
cout<<"GAUSSIAN ELIMAINATION METHOD";
goto xy;
cout<<"*****************************";
cout<<"\n\t HOW MANY EQUATION::";
cin>>faheem;
cout<<"\n\t ENTER DATA FOR EQUATIONS:";
cout<<"\n\t =========================";
for(i=0;i<=faheem-1;i++)
for(j=0;j<=faheem;j++)
{
void xy()
{
cin>>arr[i][j];
I=I+8;
if(j=faheem)
{
k++;
I=20;
}
}
}
void print_result()
{
int i,j=1;
cout<<"\n\t FINAL RESULT";
cout<<"\n\t====================================";
for(i=faheem-1;i>=0;i--)
{
cout<<"\tX"<<j++<<":\t"<<answer[i]<<endl;
}
}
void main()
{
int i,j,k,I=1,p=1;
readdata();
for(i=1;i<=faheem;i++)
{
for(j=i-1;j<=faheem;j++)
arr[faheem+i-1];[j]=arr[i-1][j]/arr[i-1][i-1];
for(j=i;i<faheem;i++)
{
temp=arr[j][i-1];
for(k=i-1;k<=faheem;k++)
arr[j][k]-=arr[faheem+i-1][k]*temp;
}
}
temp =0; k=1;
answer [0]=arr[2*faheem-1][faheem];
for(j=2*faheem-1;j>faheem;j--)
{
for(k=1;k<=p;k++)
temp+=answer[k-1]*arr[j-1][faheem-k];
answer[p++]=arr[j-1][faheem]-temp;
temp=0;
}
print_result();
return 0;
}
|
Conio.h is non-standard and deprecated:
https://en.wikipedia.org/wiki/Conio.h
Most modern compilers do not support it, and you should not use it.
Global variables are bad practice - try to modify your program to not use them.
Your indentation is abnormal try fixing it so the code reads better.
what is indentation plz tell me i m new on c++
This program is not indented:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
int main()
{
if(blah)
{
for(blah)
{
blah;
}
blah;
}
else
{
blah;
while(blah)
{
blah;
}
}
}
|
This program
is indented:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
int main()
{
if(blah)
{
for(blah)
{
blah;
}
blah;
}
else
{
blah;
while(blah)
{
blah;
}
}
}
|
@LB if not use conio.h , how to use getch();
function ?
if you want to read a character you may std::cin>>a_variable_of_type_char;
If you don't want buffer or echo, try curses.
thnx @LB
Topic archived. No new replies allowed.