Find surface of Area
#include <stdio.h>
#include <stdlib.h>
void Sufface3x3 (){
int i,j,a[10][10],det=0;
float S;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("Input your data [%d][%d]",i,j);
scanf("%d",&a[i][j]);}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
printf("%d\t ",a[i][j]);
}
printf("\n");
}
for (int i=0;i<3;i++){
det= det+ ( a[0][i]*(a[1][(i+1)%3]*a[2][(i+2)%3]-a[1][(i+2)%3]*a[2][(i+1)%3]));
S = det/2;
}
printf ("\nvalue of Surface %f",S);
}
void Suface2x2 (){
int i,j,a[10][10],determinant=0;
float s;
printf ("Please input element of matrix\n");
for (int i=0; i<2; i++){
for (int j=0; j<2; j++){
printf("[%d][%d]",i,j);
scanf ("%d",&a[i][j]);
}
}
for ( int i=0; i<2; i++){
for ( int j=0; j<2; j++){
printf ("%d\t",a[i][j]);
}
printf("\n");
}
for (int i=0; i<2; i++){
determinant = a[0][0]*a[1][1] - a[1][0]*a[0][1];
s = determinant/2;
}
printf ("the result of suface is %f",s);
}
int main (){
printf ("1: Suface 2 x 2 ");
printf ("\n2: Suface 3 x 3 ");
int choice;
printf ("\nPlease select your choice 1-2:");
scanf ("%d",&choice);
if (choice ==1) {
Suface2x2();
}
else if (choice ==2){
Sufface3x3();
}
return 0;
}
Output
0 Comments