GithubHelp home page GithubHelp logo

normangadenya / c-programming-assignment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from malep2007/c-programming-assignment

1.0 0.0 0.0 116 KB

This is a repository for students to solve some problems in the c files provided. Instructions are provided below

CMake 29.10% C 23.15% C++ 33.04% Makefile 14.72%

c-programming-assignment's Introduction

Assignment

This is a simple repository you will use to finish the assignments contained in this README.md document.

Instruction

You are to create separate files for each question and upload those to your repositories. After which you will create a pull request when you are done with your assignment. For more information on how to use GitHub, check out this link on [GitHub Flow](https://guides.github.com/introduction/flow/,"GitHub Flow").

In essence, you will fork this repository to create your own master copy of it. Do the assignment and create a pull request with your different files. which I will observe and score.

Question One

Fix the Bug in the following code so that it runs correctly

                    /* a program with problems... */
                    #include <stdio.h>
                    int x= 1:
                    main()
                    {
                        if( x = 1);
                            printf(" x equals 1" );
                        otherwise
                            printf(" x does not equal 1");
                        return 0;
                    }

Question Two

Write a header for a function named do_it() that takes three type char arguments and returns a type float to the calling program.

Write a header for a function named print_a_number() that takes a single type int argument and doesn't return anything to the calling program.

What's wrong with the following program ?

                    #include <stdio.h>
                    void print_msg( void );
                    main(){
                        print_msg("This is a message to print");
                        return 0;
                    }
                    void print_msq( void )
                    {
                        puts("This is a message to print");
                        return 0;
                    }

Question Three

Write a declaration for an array that will hold 50 type long values

Show a statement that assigns the value of 123.456 to the 50th element in the array from the above question

What is the values of x when the following statement in complete ?

    for (x = 0; x < 100; x++)

What is the value of ctr when the following statement is compelte ?

   for(ctr = 2; ctr < 10; ctr += 3)

Write a while statement to count from 1 to 100 by 3s

What is wrong with the following code fragment (MAXVALUES is not the problem !)

    for (counter = 1; counter < MAXVALUES; counter++ );
    printf("\nCounter = %d", counter);

Question Four

Write a function named addarrays() that accepts two arrays that are the same size. The function should add each element in the arrays together and place the values in a third array.

Modify the function you created to return a pointer to the array containing the totals. Place this function in a program that also displays the values in all three arrays.

c-programming-assignment's People

Contributors

malep2007 avatar normangadenya avatar

Stargazers

Alexander avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.