Thread: Help me to this please I'm begging..

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    23

    Unhappy Help me to this please I'm begging..

    this are my programs that I made before and as a project my teacher asked me to recode all my programs and compress it in one program with menu.. I was absent that time when my teacher discuss about "case" because I have asthma and I was confined at the hospital.. my teacher said to self study but its so hard for me to understand it without someone explaining it to me... so please someone help me to put all this program in MENU??

    Help me... dead line tomorrow so that I'm so scared, I'm so helpless and hopeless on how to do this...

    my teacher said to me that I can use any technique or code, but the important is its in the MENU...

    Please..... a deep thankful to everyone who can help me and give me some advice..
    good thing this kind of website is existing.. Thank you very much!!! God Bless...


    SORRY for disturbing you guys... sorry for some wrong grammars there...
    THANK YOU!!! =,)

    Code:
    Program1
    #include <stdio.h>
    #include <conio.h>
    void main()
    {
    float ar[10]={1.1};
    double ray[10]={9.29};
    float *x;
    double *y;
    int a;
    clrscr();
    x=&ar[0];
    y=&ray[0];
    
       printf("\nthe value of float is: %.2f",*x++);
       printf("\n");
       printf("\nthe value of double is: %.2lf",*y++);
    
    getch();
    }
    
    
    Program2
    #include<stdio.h>
    #include<conio.h>
    
    void floating(float arr[],float *ave, float *sum)
    {
    float a,b;
    int ctr;
    for(ctr=0;ctr<=10;ctr++)
    {
     a+=arr[ctr];
    }
     b=a/10;
     *sum=a;
     *ave=b;
    }
    
    void main()
    {
    float arr[10]={1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0};
    float sum;
    float ave;
    int ctr;
    clrscr();
    for(ctr=0;ctr<=10;ctr++);
    {
    arr[ctr];
    }
      floating( arr,&ave,&sum );
    
    printf("\n the average is : %.2f",ave);
    printf("\n the sum is : %.2f",sum);
    getch();
    }
    
    
    Program3
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    float *pf;
    int ctr;
    clrscr();
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[0];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array first to the last: %.1f",*pf++);
    }
    getch();
    }
    
    
    
    Program4
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    double *pf;
    int ctr;
    clrscr();
    for(ctr=0;ctr<=9;ctr++)
    {
     printf("\nthe array list [%d]: %.2lf",ctr, arr[ctr]);
    }
    printf("\n");
    
    	 pf=&arr[0];
         for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array first to the last: %lf",*pf++);
          }
    
    getch();
    }
    
    
    Program5
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    float *pf;
    int ctr;
    clrscr();
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[9];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array last to first: %.1f",*pf--);
    }
    getch();
    }
    
    
    
    Program6
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    double *pf;
    int ctr;
    clrscr();
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2lf",ctr , arr[ctr]);
    }
    
    printf("\n");
    
    	  pf=&arr[9];
          for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array last to first: %.2lf",*pf--);
           }
    getch();
    }

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, let's start by merging this. Do you understand how to create and manage a menu?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Nub SWE
    Join Date
    Mar 2008
    Location
    Dallas, TX
    Posts
    133
    Turn each main() function into its own function.

    Inside your new main() function, create the menu using printf(). Allow the user to input his choice from the displayed menu. Read that input in using scanf(). Run a switch statement on the input character. If 1, go function 1. If 2, do function 2.

    Code:
    switch (input_char)
    {
              case 1:
                          function1();
                          break;
              case 2:
                          function2();
                          break;
              /* ... */
              default:
                          break;
    }
    Last edited by JDGATX; 03-27-2008 at 07:49 AM.

  4. #4
    Registered User
    Join Date
    Feb 2008
    Posts
    23
    sorry ma'am but I don't know how to start.. and I don't know how to separate those functions and those variables...

    I tried

    Code:
    if (option==1)
    printf("******");
    
    else if (option==2)
    printf("********");
    
    else if(option==3)
    exit();
    else
    go to ct;
    I tried that program but too much errors... I got 25 errors... and its all because of declaring a variable is not allowed..
    like this...
    Code:
    #include <stdio.h>
    #include <conio.h>
    void main()
    {
    float ar[10]={1.1};
    double ray[10]={9.29};
    float *x;
    double *y;
    int a;
    x=&ar[0];
    y=&ray[0];
    float a,b;
    int ctr;
    float arr[10]={1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0};
    float sum;
    float ave;
    float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    float *pf;
    double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    double *pf;
    float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    float *pf;
    double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    double *pf;
    
    int ctr;
    
    
    ct:
    printf("Main Menu\n");
    printf("\n\n1)Program that declares one float variable and one double data type variable");
    printf("\n 2)");
    printf("\n 3)");
    printf("\n 4)Compute the sum and average of the elements of the array");
    printf("\n 5)Initialize the array, set a pointer that points to the first, and print all the elements of the array from the first down to the last");
    printf("\n 6)Double data type accessing the array elements");
    printf("\n 7)Initialize the array, set a pointer that points to the last, and print all the elements of the array from the first down to the last");
    printf("\n 8)with 10 double data type elements");
    printf("\n 9)Exit");
    printf("Enter your choice");
    scanf("%d",&option);
    if(option==1)
    
    
       printf("\nthe value of float is: %.2f",*x++);
       printf("\n");
       printf("\nthe value of double is: %.2lf",*y++);
    
    
    else if(option==2)
    
    
    void floating(float arr[],float *ave, float *sum)
    {
    
    for(ctr=0;ctr<=10;ctr++)
    {
     a+=arr[ctr];
    }
     b=a/10;
     *sum=a;
     *ave=b;
    }
    
    
    {
    
    for(ctr=0;ctr<=10;ctr++);
    {
    arr[ctr];
    }
      floating( arr,&ave,&sum );
    
    printf("\n the average is : %.2f",ave);
    printf("\n the sum is : %.2f",sum);
    
    
    else if(option==3)
    
    {
    
    
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[0];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array first to the last: %.1f",*pf++);
    }
    
    else if(option==4)
    
    {
    
    for(ctr=0;ctr<=9;ctr++)
    {
     printf("\nthe array list [%d]: %.2lf",ctr, arr[ctr]);
    }
    printf("\n");
    
    	 pf=&arr[0];
         for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array first to the last: %lf",*pf++);
          }
    
    
    else if(option==5
    
    
    
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[9];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array last to first: %.1f",*pf--);
    }
    
    
    else if(option==6)
    
    
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2lf",ctr , arr[ctr]);
    }
    
    printf("\n");
    
    	  pf=&arr[9];
          for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array last to first: %.2lf",*pf--);
           
    
    else if(option==7)
    exit();
    else
    go to ct;
    }
    I know its crazy but I don't have any option.. I got mental blocked.. ='(

  5. #5
    Nub SWE
    Join Date
    Mar 2008
    Location
    Dallas, TX
    Posts
    133
    You didn't define option anywhere.

    Code:
    int option;
    In some of your functions, it seems like you're defining and initializing arr, and then using a for loop two steps later to overwrite everything you initialized. Unfortunately, your statement isn't even doing that correctly. This statement has no effect:

    Code:
    	for(ctr=0;ctr<10;ctr++);
    	{
    		arr[ctr];
    	}
    You're also going to run into some buffer overrun problems using your for loop. You shouldn't be checking ctr <= 10. You should be checking ctr < 10, if you start ctr at 0.

    Code:
    void floating(float arr[],float *ave, float *sum)
    {
    	float a,b;
    	int ctr;
    	for(ctr=0;ctr<10;ctr++)
    	{
    		a+=arr[ctr];
    	}
    	b=a/10;
    	*sum=a;
    	*ave=b;
    }
    Last edited by JDGATX; 03-27-2008 at 08:02 AM.

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    23
    so I have to specify each and change their variable name??? yes I already Initialize option but their still an error: declaration on variable not allowed..

  7. #7
    Registered User
    Join Date
    Feb 2008
    Posts
    23
    sir each of my programs has no error.. the error is when I recode it into MENU... ahhh.... I'm so idiot.... I don't know how to deal with this... aarrrghhh..... anyway so many thanks to you sir... sorry because I wasted your... Thanks a lot god bless

  8. #8
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Since it is a C program,
    1)Declarations should come first.
    2)Multiple declarations are not allowed in C.
    u have declared variables twice.try deleting any one of them.
    3)instead of using goto try a while(1) loop
    And finally don't paste the function definition and paste only the code inside it.
    Hope it helps.
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    When you are combining different source files, it's not just a case of "copy and paste and re-arrange the lines" - you need to make more changes than that.

    For example, you now have several variables all called "arr", "sum" and "pf" (for example). In some cases, you even have differing types.

    Where the variables are identical (both type, name and content), you could just remove the duplicates.

    In case where you have different types or values (content), you will need to change the name.

    You are defining a function inside main:
    Code:
    void floating(float arr[],float *ave, float *sum)
    {
    
    for(ctr=0;ctr<=10;ctr++)
    {
     a+=arr[ctr];
    }
     b=a/10;
     *sum=a;
     *ave=b;
    }
    This is not valid C, each function must be defined outside any other function.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Registered User
    Join Date
    Feb 2008
    Posts
    23
    thanks with you too... I'll try to recode this till death, until it run

  11. #11
    Nub SWE
    Join Date
    Mar 2008
    Location
    Dallas, TX
    Posts
    133
    Quote Originally Posted by lesrhac03 View Post
    sir each of my programs has no error.. the error is when I recode it into MENU... ahhh.... I'm so idiot.... I don't know how to deal with this... aarrrghhh..... anyway so many thanks to you sir... sorry because I wasted your... Thanks a lot god bless

    I wouldn't give up. We're almost there.

    Can you give me the line of code that your error is occuring on? I've got a compiled program here that I'm working with.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by lesrhac03 View Post
    thanks with you too... I'll try to recode this till death, until it run
    Make sure you UNDERSTAND what you are changing - if you just randomly change it, you will NOT make it run. If you don't understand what the change does, ask...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    and the hat of copycat stevesmithx's Avatar
    Join Date
    Sep 2007
    Posts
    587
    Hey I have cleared syntax errors in ur program.
    Dont blame me if they have logical errors.
    I havent looked upon them .
    And I haven't indented them too.

    Code:
    #include <stdio.h>
    #include <conio.h>
    void main()
    {
    float ar[10]={1.1};
    double ray[10]={9.29};
    float *x;
    double *y;
    float a,b;
    int ctr;
    float sum;
    float ave;
    float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    float *pf;
    int option;
    
    
    
    x=&ar[0];
    y=&ray[0];
    
    while(1){							//don't use goto
    printf("Main Menu\n");
    printf("\n\n1)Program that declares one float variable and one double data type variable");
    printf("\n 2)");
    printf("\n 3)");
    printf("\n 4)Compute the sum and average of the elements of the array");
    printf("\n 5)Initialize the array, set a pointer that points to the first, and print all the elements of the array from the first down to the last");
    printf("\n 6)Double data type accessing the array elements");
    printf("\n 7)Initialize the array, set a pointer that points to the last, and print all the elements of the array from the first down to the last");
    printf("\n 8)with 10 double data type elements");
    printf("\n 9)Exit");
    printf("Enter your choice");
    scanf("&#37;d",&option);
    if(option==1){
    
    
       printf("\nthe value of float is: %.2f",*x++);
       printf("\n");
       printf("\nthe value of double is: %.2lf",*y++);
    }
    
    else if(option==2){
    for(ctr=0;ctr<=10;ctr++)
    {
     a+=arr[ctr];
    }
     b=a/10;
     sum=a;
     ave=b;
    /*for(ctr=0;ctr<=10;ctr++);
    {
    arr[ctr];					//??????
    } */
    printf("\n the average is : %.2f",ave);
    printf("\n the sum is : %.2f",sum);
    }
    
    else if(option==3)
    
    {
    
    
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[0];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array first to the last: %.1f",*pf++);
    }
    }
    else if(option==4)
    
    {
    
    for(ctr=0;ctr<=9;ctr++)
    {
     printf("\nthe array list [%d]: %.2lf",ctr, arr[ctr]);
    }
    printf("\n");
    
    	 pf=&arr[0];
         for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array first to the last: %lf",*pf++);
          }
    
     }
    else if(option==5){
    
    
    
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    }
    printf("\n");
         pf=&arr[9];
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\n elemnts of the array last to first: %.1f",*pf--);
    }
    }
    
    else if(option==6)
    {
    for(ctr=0;ctr<=9;ctr++)
    {
      printf("\nthe array list [%d]: %.2lf",ctr , arr[ctr]);
    }
    
    printf("\n");
    
    	  pf=&arr[9];
          for(ctr=0;ctr<=9;ctr++)
          {
    	printf("\n elemnts of the array last to first: %.2lf",*pf--);
    
    }
    }
    else
    exit();
    }
    }
    Not everything that can be counted counts, and not everything that counts can be counted
    - Albert Einstein.


    No programming language is perfect. There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
    - Herbert Mayer

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's one big mess when not indented:
    Code:
    #include <stdio.h>
    #include <conio.h>
    void main()
    {
    	float ar[10]={1.1};
    	double ray[10]={9.29};
    	float *x;
    	double *y;
    	float a,b;
    	int ctr;
    	float sum;
    	float ave;
    	float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    	float *pf;
    	int option;
    
    
    
    	x=&ar[0];
    	y=&ray[0];
    
    	while(1){							//don't use goto
    		printf("Main Menu\n");
    		printf("\n\n1)Program that declares one float variable and one double data type variable");
    		printf("\n 2)");
    		printf("\n 3)");
    		printf("\n 4)Compute the sum and average of the elements of the array");
    		printf("\n 5)Initialize the array, set a pointer that points to the first, and print all the elements of the array from the first down to the last");
    		printf("\n 6)Double data type accessing the array elements");
    		printf("\n 7)Initialize the array, set a pointer that points to the last, and print all the elements of the array from the first down to the last");
    		printf("\n 8)with 10 double data type elements");
    		printf("\n 9)Exit");
    		printf("Enter your choice");
    		scanf("%d",&option);
    		if(option==1){
    
    
    			printf("\nthe value of float is: %.2f",*x++);
    			printf("\n");
    			printf("\nthe value of double is: %.2lf",*y++);
    		}
    
    		else if(option==2){
    			for(ctr=0;ctr<=10;ctr++)
    			{
    				a+=arr[ctr];
    			}
    			b=a/10;
    			sum=a;
    			ave=b;
    			/*for(ctr=0;ctr<=10;ctr++);
    			{
    			arr[ctr];					//??????
    			} */
    			printf("\n the average is : %.2f",ave);
    			printf("\n the sum is : %.2f",sum);
    		}
    
    		else if(option==3)
    
    		{
    
    
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    			}
    			printf("\n");
    			pf=&arr[0];
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\n elemnts of the array first to the last: %.1f",*pf++);
    			}
    		}
    		else if(option==4)
    
    		{
    
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\nthe array list [%d]: %.2lf",ctr, arr[ctr]);
    			}
    			printf("\n");
    
    			pf=&arr[0];
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\n elemnts of the array first to the last: %lf",*pf++);
    			}
    
    		}
    		else if(option==5){
    
    
    
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    			}
    			printf("\n");
    			pf=&arr[9];
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\n elemnts of the array last to first: %.1f",*pf--);
    			}
    		}
    
    		else if(option==6)
    		{
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\nthe array list [%d]: %.2lf",ctr , arr[ctr]);
    			}
    
    			printf("\n");
    
    			pf=&arr[9];
    			for(ctr=0;ctr<=9;ctr++)
    			{
    				printf("\n elemnts of the array last to first: %.2lf",*pf--);
    
    			}
    		}
    		else
    			exit();
    	}
    }
    Let's make sure it works before suggesting trivial changes that needs to be made.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #15
    Nub SWE
    Join Date
    Mar 2008
    Location
    Dallas, TX
    Posts
    133
    The one I put together uses a switch statement as requested.

    And it's not one huge clusterf***.

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    void function_one();
    void function_two();
    void function_three();
    void function_four();
    void function_five();
    void function_six();
    void floating(float arr[],float *ave, float *sum);
    
    int main(void)
    {
    	int user_choice;
    	char throwaway;
    	
    	while(1)
    	{
    		/** Create menu. */
    		printf("Here are your choices:\n");
    		printf("*** Enter 1 for function_one.\n");
    		printf("*** Enter 2 for function_two.\n");
    		printf("*** Enter 3 for function_three.\n");
    		printf("*** Enter 4 for function_four.\n");
    		printf("*** Enter 5 for function_five.\n");
    		printf("*** Enter 6 for function_six.\n");
    		printf("*** Enter 7 to EXIT!\n");
    		printf("-----------------------------------\n");
    		printf("Enter your choice now 1 - 6:");
    		fflush(stdout);
    		scanf("%d", &user_choice);
    		
    		/** Switch statement on user choice. */
    		switch(user_choice)
    		{
    			case 1:
    				printf("Function_one EXECUTING!\n");
    				function_one();
    				break;
    			case 2:
    				function_two();
    				break;
    			case 3:
    				function_three();
    				break;
    			case 4:
    				function_four();
    				break;
    			case 5:
    				function_five();
    				break;
    			case 6:
    				function_six();
    				break;
    			case 7:
    				printf("Exiting! Press ENTER to exit!\n");
    				fflush(stdout);
    				scanf("%c", &throwaway);
    				return 0;
    			default:
    				printf("You've entered an incorrect choice.\n");
    				fflush(stdout);
    				break;
    		}
    	}
    	
    	return 0;
    }
    
    void function_one()
    {
    	float ar[10]={1.1};
    	double ray[10]={9.29};
    	float *x;
    	double *y;
    
    	
    	x=&ar[0];
    	y=&ray[0];
    
    	printf("\nthe value of float is: %.2f",*x++);
    	printf("\n");
    	printf("\nthe value of double is: %.2lf",*y++);
    }
    
    
    void floating(float arr[],float *ave, float *sum)
    {
    	float a,b;
    	int ctr;
    	for(ctr=0;ctr<10;ctr++)
    	{
    		a+=arr[ctr];
    	}
    	b=a/10;
    	*sum=a;
    	*ave=b;
    }
    
    void function_two()
    {
    	float arr[10]={1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0};
    	float sum;
    	float ave;
    	
    	floating( arr,&ave,&sum );
    
    	printf("\n the average is : %.2f",ave);
    	printf("\n the sum is : %.2f",sum);
    }
    
    
    void function_three()
    {
    	float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    	float *pf;
    	int ctr;
    
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    	}
    	printf("\n");
    	pf=&arr[0];
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\n elemnts of the array first to the last: %.1f",*pf++);
    	}
    }
    
    
    
    
    void function_four()
    {
    	double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    	double *pf;
    	int ctr;
    
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\nthe array list [%d]: %.2lf",ctr, arr[ctr]);
    	}
    	printf("\n");
    
    	pf=&arr[0];
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\n elemnts of the array first to the last: %lf",*pf++);
    	}
    }
    
    
    void function_five()
    {
    	float arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    	float *pf;
    	int ctr;
    	
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\nthe array list [%d]: %.2f",ctr , arr[ctr]);
    	}
    	
    	printf("\n");
    	
    	pf=&arr[9];
    	
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\n elemnts of the array last to first: %.1f",*pf--);
    	}
    }
    
    
    void function_six()
    {
    	double arr[10]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0};
    	double *pf;
    	int ctr;
    	
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\nthe array list [%d]: %.2lf",ctr , arr[ctr]);
    	}
    
    	printf("\n");
    
    	pf=&arr[9];
    	
    	for(ctr=0;ctr<10;ctr++)
    	{
    		printf("\n elemnts of the array last to first: %.2lf",*pf--);
    	}
    }
    Unfortunately, despite what you say, some of your functions do have errors in them. Best of luck.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help A Noob Here (plz Im Begging You)
    By bobbie18 in forum C Programming
    Replies: 97
    Last Post: 03-28-2008, 03:38 AM
  2. Begging on wall street
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-04-2004, 04:50 PM
  3. Replies: 3
    Last Post: 08-18-2004, 07:39 AM