Q

C Language and Procedural Programming Assignment Help

C Language and Procedural Programming Assignment Help - Hire Best Online Tutors at Miracleskills For C Language and Procedural Programming Assignment Help Service!!
Previous << >> Next

Assessment Brief -

Overall Aim - To give students an understanding of the C language and procedural programming including features such as functions, pointers, loops and control statements.

Assignment Aims - The aim of this assignment is to write a brief report explaining and documenting selected lab solutions already undertaken by the student throughout the year.

MOST RELIABLE AND TRUSTWORTHY C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENT HELP & HOMEWORK WRITING SERVICES AT YOUR DOORSTEPS!

Tasks - Write a brief report on each of the four identified lab questions below. The report should detail the student's high level solution to the problem including:

  • Any difficulties encountered.
  • Why they chose to solve the problem the way they did (many of the exercises have multiple possible solutions).
  • Any limitations they feel their program has.
  • What alternative solutions there may be (this may include more advanced techniques that the student had not encountered at the time of the exercise E.G. pointers, functions etc.).

The student should also provide the source code for their solution which should include comments in the code explaining any relevant sections.

Lab Question -

Deal with endless assignments without any hassle by getting the support of experienced professionals from the best online Diploma assignment help in the UK.

LAB 1 Question - In previous exercises we've used getchar() to prevent VS from closing the output window but what the function really does is read in a character from the keyboard. We can store the character retrieved by placing it in a char variable like so:

char input;

input = getchar();

The char entered by the user is now stored in the variable input.

Write a simple program that reads in 3 characters from the keyboard, and outputs to the screen on one line all three characters and the sum of their ASCII values.

SAVE DISTINCTION MARKS IN EACH C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENT WHICH IS WRITTEN BY OUR PROFESSIONAL WRITER!

LAB 2 Question - Write a program that asks the user to input a month of the year (1-12) and a day in the month (1-31). The program should check whether the date is valid and return the season the date is in.

Useful information: UK season dates are:

Spring - March 20th to June 20th

Summer - June 21st to Sept 21st

Autumn - Sep 22nd to Dec 20th

Winter - Dec 21st - March 19th.

LAB 3 Question - Ask a user to type in a short message for inclusion in a twitter message (280 Characters or less). Once the users has typed in the message the program should:

i) Repeat the message.

ii) Display statistics showing :

a. Total number of non-white space characters in the message.

b. Total number of number in the message.

c. Total number of lower case letters in the message.

d. Total Number of upper case letters in the message.

e. Total Number of non-alphanumeric or white space characters in the message.

The most common character in the message.

HIRE PROFESSIONAL WRITER FROM MIRACLESKILLS.COM AND GET BEST QUALITY C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENT HELP AND HOMEWORK WRITING SERVICES!

LAB 4 Question - File Input / Output (I/O)

In many circumstances our programs need to read and write to files, this tutorial will look at file handling in C.

The template for declaring a file in C looks like the following: FILE *fp;

FILE *fopen(char *name, char *mode);

So fp is a pointer and FILE is a datatype (like short, int, float etc.). To call fopen in a program we use :

fp = fopen(name, mode);

Here name is the filename and mode refers to what we intend to do with the file. The usual modes are ("r") for read, ("w") for write and ("a") for append. We can also specify whether the file is binary or text, for our purposes we will just be using text files (the most common).

Below is an example of a simple Program to save some text to a file:

#include<stdio.h>

main()

{

FILE *fp;

char input[255];

fp = fopen("test.txt","a");

printf("Please enter some text to write to the file : \n");

scanf("%[^\n]s", input);

fprintf(fp, "%s\n", input);

fclose(fp);

printf("\n");

printf("Done.");

}

There are a few new things here so let's look at them.

FILE *fp; declares our file pointer (it doesn't have to be called fp). input is a char array that will hold the user's input.

fp = fopen("test.txt","a"); this line opens the file where the text will go, "test.txt" is the name of the file and "a" is the mode. In this case we are using append mode, if the file already exists then the program will add new text to the end of it, if the file doesn't exist the program will create it. We could have used "w" for write, in that case the program would again create the file if it didn't exist but if it did exist it would overwrite any text in it.

We then ask the user for the text for the file. Notice the scanf line is slightly different than before. The part "%[^\n]s" is different than the usual "%s" for string the extra [^\n] tells scanf to keep accepting input until it gets to an end of line (EOL) symbol, this is when the user hits enter. If we use "%s" then scanf will stop as soon as it gets to any whitespace (spaces, tabs etc.).

The next line writes the text into the file:

fprintf(fp, "%s\n", input);

fprintf is the function for writing to the file (there are other functions that can be used such as fputs). fprintf needs three parameters : the file pointer (fp), the format of the data being written ("%s\n") here we are writing a string followed by a newline, and the data being written (input).

Finally we close the file and report back that we have finished.

WE HELP STUDENTS TO IMPROVE THEIR GRADES! AVAIL TOP QUALITY C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENT HELP AND HOMEWORK WRITING SERVICES AT CHEAPER RATE!

We can check the contents of the file by loading it into a text editor (notepad etc.).

Reading Files.

So much for writing what about getting the data out of a file and into a program. The program below is a simple C program that opens a file and writes the contents into a char array.

#include<stdio.h>

main()

{

FILE *fp;

char input[255];

fp = fopen("test.txt","r");

fscanf(fp, "%[^\n]s", input);

fclose(fp);

printf("Contents of the file are :\n %s \n", input);

}

Not too much different here, this time we open the file using the "r" mode for reading (we can't write anything to the file in this mode). To read the data in the file we are using fscanf (again other functions can do this like fgets), fscanf is similar to fprintf in that it needs to know the file pointer, the datatype and where to store the incoming data. Again we've used "%[^\n]s" to keep scanning until we hit an end of line.

Notes - Both of the programs here will write and read one line to and from a file. We also have to be careful that we are not trying to write or read more than 255 characters or we will have problems with array overflow.

Question 1 - Write a program that will read it 5 lines of text from a user and write it to a file.

Question 2 - Write a program that will read in the 5 lines of text from 1. And print them to the screen. (Hint for 1 and 2 remember loops).

Question 3 - Write a program that asks the user for two filenames and checks whether the two files given have the same first line.

NEVER MISS YOUR CHANCE TO EXCEL IN C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENT! AVAIL AFFORDABLE AND RELIABLE C LANGUAGE AND PROCEDURAL PROGRAMMING ASSIGNMENTS HELP SERVICES OF MIRACLESKILLS.COM!


Want to Excel in Course? Hire Trusted Writers for Help! —> https://miracleskills.com/

Lists of comments


Leave a comment


Captcha