Question

Hello. my assignment requires to create a program using the C language and that must contain...

Hello.

my assignment requires to create a program using the C language and that must contain the following:

- Error Checking

- Use of Functions

- Menu system

- Array Processing

-No Global variables

the theme of the program can be about anything but must contain the features mentioned above

Thanks in advance

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION-

I have same porblem to other student below is the corrrect answer :)

SOLUTION-

I have solved the code in C program below with all the 4 methods you can check it below :)

CODE-

//c code

#include <stdio.h>
#include <errno.h>
#include <string.h>

int add(int a, int b){
    return a+b;
}

int main ()
{
    //error handling
    FILE *fp;

    // If a file is opened which does not exist,
    // then it will be an error and corresponding
    // errno value will be set
    fp = fopen(" SAMPLE.txt ", "r");

    // opening a file which does
    // not exist.
    printf("Value of errno: %d\n ", errno);
    printf("The error message is : %s\n",strerror(errno));
    perror("Message from perror");
  
    //Use of functionS
    int d = add(1,2);
    printf("Sum of 1 & 2 is: %d",d);

  
    //menu system
    int x;
    printf("\nSelect an item: ");
    printf("\n1. Add");
    printf("\n2. Subtract");
    printf("\n3. Multiply\n");
    scanf("%d",&x);
    switch (x) {
        case 1:
            printf("Add selected\n");
            break;
        case 2:
            printf("Subtarct selected\n");
            break;
        case 3:
            printf("Multiply selected\n");
            break;
          
        default:
            break;
    }
  
    //array processing
    int arr[3] = {1,2,3};
    for(int i = 0;i<3;i++){
        printf("%d ",arr[i]*3);
    }
  
    return 0;
}

SCREENSHOT-

mail YouTube History Downloads WhatsApp Run Debug Stop Share Save {}BE beta er for perror(Message from perror); bug I/Use o

IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------

Add a comment
Know the answer?
Add Answer to:
Hello. my assignment requires to create a program using the C language and that must contain...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program...

    PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...

  • Submissions are accepted in program codes in C PROGRAMMING LANGUAGES COURSE ASSIGNMENT Design your own general purpose programming language which will be completely in english Your language design...

    Submissions are accepted in program codes in C PROGRAMMING LANGUAGES COURSE ASSIGNMENT Design your own general purpose programming language which will be completely in english Your language design must include the following A general skeleton of a program State diagrams for the following (35 pts) . Identifier Unsigned integer Unsigned constant Constant Variable Factor and term rules similar to the ones given in your textbook Simple expression Compound expression . Parameter list Simple type 1D Array type Statement Block Loop...

  • Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program...

    Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...

  • Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...

    Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...

  • In this assignment you will create two Java programs: The first program will be a class...

    In this assignment you will create two Java programs: The first program will be a class that holds information (variables) about an object of your choice and provides the relevant behavior (methods) The second program will be the main program which will instantiate several objects using the class above, and will test all the functions (methods) of the class above. You cannot use any of the home assignments as your submitted assignment. Your programs must meet the following qualitative and...

  • Please design, write the code and create the requisite submission files in C++ for the following...

    Please design, write the code and create the requisite submission files in C++ for the following problem: A menu-driven program that offers the user 5 options as follows: Menu: 1. Display array 2. Add up all elements in the array and display that number. 3. Add 1 to each element in the array. 4. Swap the values in row one with the values in row three. 5. Exit In main(), declare and initialize a 2-dimensional array that contains 5 x...

  • Language: C# In this assignment we are going to convert weight and height. So, the user...

    Language: C# In this assignment we are going to convert weight and height. So, the user will have the ability to convert either weight or height and as many times as they want. There conversions will only be one way. By that I mean that you will only convert Pounds to Kilograms and Feet and Inches to Centimeters. NOT the other direction (i.e. to Pounds). There will be 3 options that do the conversion, one for each type of loop....

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • I am using programming language of DEV C++, and here is my assignment. Write a program,...

    I am using programming language of DEV C++, and here is my assignment. Write a program, maxmin.c to find the maximum and minimum of values in the file maxminin.txt. Your output should look like: There are 6 values in the file The maximum value is 9.500000 The minimum value is 1.100000 and this is maxminin.txt: 8.2 1.1 3.7 2.2 9.5 4.3

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT