6 Replies - 558 Views - Last Post: 02 July 2013 - 09:37 AM Rate Topic: -----

#1 zille   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-June 13

Multiple Task in one Program two error

Posted 02 July 2013 - 08:30 AM

I am having two error in the program.

Can anyone help:

//
//  main.c
//  assignment
//
//  Created by Khondakar Zille Mowla on 7/2/13.
//  Copyright (c) 2013 Khondakar Zille Mowla. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

void header ()
{
    printf("&&&&&&&&&&&&&&&&&&&&&&&\n");
    printf("Welcome to this program");
    printf("&&&&&&&&&&&&&&&&&&&&&&&\n");
}

void displaymenu()
{
    printf("Please select any task from following options");
    printf("A To Perform Substraction");
    printf("B to Calculate the Average Value");
    printf("C to Determine the Median Value");
    printf("D to display a Rectangle");
    printf("E to Exit the Program");
}

void substraction()
{
    int int1, int2, sub;
    printf("Enter first Integer\n");
    scanf("%d", &int1);
    printf("Enter Second Integer\n");
    scanf("%d", &int2);
    sub=int1-int2;
    printf("The substraction of the two integer %d and %d is %d", int1, int2, sub);
}
void average()
{
    float flo1, flo2, flo3, average;
    printf("Please enter three number to calculate average");
    scanf("%f%f%f", &flo1, &flo2, &flo3);
    average = (flo1 + flo2 + flo3) / 3;
    printf("The average of %f, %f and %f is %f", flo1, flo2, flo3, average);
}
void median()
{
    int h, i, j;
    int median;
    printf("Please enter three integer to determine the median");
    scanf("%d%d%d", &h, &i, &j);
    if ((i >= h && i <= j) ||
        (i >= j && i <= h)) median = i;
    else if ((h >= i && h <= j) ||
             (h >= j && h <= i)) median = h;
    else
        median = j;
    printf("The median for %d, %d and %d is %d ", h, i, j, median);

}
void rectangle()
{
    const int row = 5;
	int width;
    printf("Please enter width for the rectangle");
    scanf("%d",&width);
    
	for(int i = 0;i<row;i++){
		for(int j = 0;j<width;j++){
			printf("*");
        }
        printf("\n"); (FIRST ERROR HERE)
}
int main()
{

    char option;
	int counter1 = 0,counter2 = 0,counter3 = 0,counter4 = 0;
    
	header();
	displayList();
    
	do{
		
        scanf("%c",&option);
        switch(tolower(option))
        {
            case 'a':
                substraction();
                displaymenu();
                counter1++;
                break;
            case 'b':
                average();
                displaymenu();
                counter2++;
                break;
            case 'c':
                median();
                displaymenu();
                counter3++;
                break;
            case 'd':
                rectangle();
                displaymenu();
                counter4++;
                break;
            case 'e':
                printf("You Have Chosen option A for: %d\n",counter1);
                printf("You Have Chosen option B for: %d\n",counter2);
                printf("You Have Chosen option C for: %d\n",counter3);
                printf("You Have Chosen option D for: %d\n",counter4);
                system("pause");
                exit(0);
        }
        
	}while(option != 'e');
    
	system("pause");
} (SECOND ERROR HERE)




Is This A Good Question/Topic? 0
  • +

Replies To: Multiple Task in one Program two error

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 08:31 AM

And your errors are...?
Was This Post Helpful? 0
  • +
  • -

#3 zille   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-June 13

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 08:32 AM

Both error says: Expected ';' at end of declaration
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 08:33 AM

Post your errors exactly as they are occurring so we don't have to hunt through your code.
Was This Post Helpful? 0
  • +
  • -

#5 zille   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-June 13

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 08:34 AM

I am using XCODE for this program.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 08:36 AM

This is getting ridiculous. I'm not hunting through your code for two lines without semi-colons. If you're not going to post your error messages with the line numbers, I'm closing the thread.
Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg   User is offline

  • member icon

Reputation: 5916
  • View blog
  • Posts: 17,932
  • Joined: 25-December 09

Re: Multiple Task in one Program two error

Posted 02 July 2013 - 09:37 AM

You seem to have mismatched braces. Insure they match.

Jim
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1