Expected bracket and unterminated string problem

This is a discussion on Expected bracket and unterminated string problem within the C Programming forums, part of the General Programming Boards category; I am building a program which accepts a number between 5 and 95 and sorts that number into change of ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    4

    Expected bracket and unterminated string problem

    I am building a program which accepts a number between 5 and 95 and sorts that number into change of 50-20-10 and 5 cent pieces.
    It has the errors:

    line 3- ) expected
    line 6- unterminated string or character constant.
    I am confused on how to fix these errors.

    Code:
    #include <stdio.h>
    
    int takenum(int &num)
    	{
    	printf("Please input change:");
    	scanf("%d%*c", &num");
    	return(num);
    	}
    	
    int calc(int num, int fifty, int twenty, int ten, int five)
    {
    		while(num >= 5 && num <= 95)
    	{
    		if(num >= 50)
    		{
    			fifty++;
    			num-=50;
    		}
    		else
    			if(num >= 20)
    			{
    				twenty++;
    				num-=20;
    			}
    			else
    				if(num >= 10)
    				{
    					ten++;
    					num-=10;
    				}
    				else
    					if(num >= 5)
    					{
    							five++;
    						num-=5;
    					}
    	}
    	return(fifty, twenty, ten, five);
    }
    
    void print(int fifty, int twenty, int ten, int five)
    {
    	printf("Number of 50 cents %d", fifty);
    	printf("Number of 20 cents %d", twenty);
    	printf("Number of 10 cents %d", ten);
    	printf("Number of 5 cents %d", five);
    }
    
    int main()
    {
    
    	int takenum(int num);
    	int calc(int num, int fifty, int twenty, int ten, int five);
    	void print(int fifty, int twenty, int ten, int five);
    	return(0);
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,313
    Is this supposed to be C or C++? You posted in the C programming forum, but the reason for the error is that you are using C++ syntax.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    Code:
    int takenum(int &num)
    	{
    	printf("Please input change:");
    	scanf("%d%*c", &num");
    	return(num);
    	}
    	
    int calc(int num, int fifty, int twenty, int ten, int five)
    {
                //you can't do this. Only 1 value is allowed to be returned
    	return(fifty, twenty, ten, five);
    }
    I suggest you re-read through your textbook or take a look at the tutorials we have available at this site.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. error:unterminated character constant
    By Figen in forum C Programming
    Replies: 6
    Last Post: 01-31-2011, 02:08 PM
  2. Replies: 2
    Last Post: 12-19-2010, 11:36 PM
  3. Bracket select
    By DrSnuggles in forum C++ Programming
    Replies: 18
    Last Post: 12-18-2007, 07:39 AM
  4. returning an appropriate string for an expected int value ??
    By Neildadon in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2003, 12:35 PM
  5. Compile Error: Unterminated character constant??
    By JamMan in forum C++ Programming
    Replies: 6
    Last Post: 11-14-2001, 04:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21