Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need assistance with C: Sorry about whitespace/formatting. code doesnt transcrib

ID: 663271 • Letter: N

Question

Need assistance with C:

Sorry about whitespace/formatting. code doesnt transcribe well into the text input with chegg...

Entering on a new line into a 2d array the points of a triangle. See my code vs. the output I am attempting.

I've tried it several ways and I just dont know what to do. I have two books that are useless with what I am trying to do. The while loop isn't needed but I want the incremented n value and the while loop was just a test to try it out. If you know a simpler way, please share.

My desired output:

Bold is user input.

If there is a different way to achieve this, any advice is welcome.

My code: for(x = 0; x < 3; x++){
for(y = 0; y < 2; y++){
int n = 1;
while (n < 3){
printf("Enter point #%d as x and y: ", n);
scanf("%d", &points[x][y]);
++n;
}
}
}

Explanation / Answer

#include<stdio.h>
#include<conio.h>

void main()
{
int points[3][2];
int x,y;
clrscr();
for(x = 0; x < 3; x++)
{
printf("Enter point # %d as x and y: ", x+1);
for(y = 0; y < 2; y++)
{
scanf("%d", &points[x][y]);
}
}
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote