Thread: midpoint programming

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    4

    Post midpoint programming

    where is my mistake ? and i wanna put while loop for x1,y1 x2,y2 where can i put
    thanks

    Code:
    #include<stdio.h>int main(){
    
    
    	float midpoint;
    	int x1,y1,x2,y2;
    
    
    	printf("enter first point x1,y1 ");
    	fflush(stdout);
    	scanf("%d %d ",&x1,&y1);
    
    
    	printf("enter second point x2,y2");
    	fflush(stdout);
    	scanf("%d %d ",&x2,&y2);
    
    
    	midpoint=(x1+x2)/2,(y1+y2)/2;
    
    
    	printf("midpoint is %f %f",midpoint);
        fflush(stdout);
        scanf("%f",&midpoint);
    
    
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    where is my mistake ?
    Perhaps you can elaborate on what the program is not doing that you expect it to do.

    Heed the warnings from your compiler.

    Code:
    main.c||In function 'main':|
    main.c|18|warning: value computed is not used|
    main.c|21|warning: too few arguments for format|
    ||=== Build finished: 0 errors, 2 warnings ===|
    Line 18 does not do what you think it does. You can only assign one value to a single variable. Perhaps you should start by finding the midpoint for x and y separately (i.e. separate variables).

    The same goes for line 21. If you want to print two values, you should be using two variables.

    and i wanna put while loop for x1,y1 x2,y2 where can i put
    What exactly do you want your program to repeat? Whatever that might be, put those lines of code within a loop. Give it a shot and let us know if you encounter any difficulties.
    Last edited by Matticus; 03-28-2013 at 01:00 PM. Reason: fixed line numbering

  3. #3
    Registered User
    Join Date
    Mar 2013
    Posts
    4
    thanks i understood my mistakes i wanna put while loop because in my homework there are a lot of points whatever

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-11-2012, 01:03 AM
  2. Replies: 4
    Last Post: 12-11-2011, 04:25 PM
  3. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM