Q

Digital Electronics and Programmable Systems Assignment Help

ER1731 Digital Electronics and Programmable Systems Assignment Help - Are You looking for ER1731 Digital Electronics and Programmable Systems Assignment Help and Online Tutor Service?
Previous << >> Next

HIRE PROFESSIONAL WRITER FROM MIRACLESKILLS.COM AND GET BEST QUALITY ER1731 DIGITAL ELECTRONICS AND PROGRAMMABLE SYSTEMS ASSIGNMENT HELP AND ASSESSMENT WRITING SERVICES!

Digital Electronics and Programmable Systems

Do not get stressed while writing your assignments since our HND assignment help services are always available for the most extensive support online.

LAB - Program 1

In previous Programs 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.

LAB Program 2

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.

MOST RELIABLE AND TRUSTWORTHY ER1731 DIGITAL ELECTRONICS AND PROGRAMMABLE SYSTEMS ASSIGNMENT HELP & ASSESSMENT WRITING SERVICES AT YOUR DOORSTEPS!

LAB Program 3 (WHILE AND FOR)

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 :

a) Repeat the message.

b) Display statistics showing :
• Total number of non-white space characters in the message.
• Total number of number in the message.
• Total number of lower case letters in the message.
• Total Number of upper case letters in the message.
• Total Number of non-alphanumeric or white space characters in the message.

The most common character in the message.

Thermodynamic Principles and Practice Assignment Help, Unit 31 Thermodynamic Principles and Practice - BTEC Level 3 National Extended Diploma in Engineering

LAB Program 4

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);

GET ASSURED A++ GRADE IN EACH ER1731 DIGITAL ELECTRONICS AND PROGRAMMABLE SYSTEMS ASSIGNMENT ORDER - ORDER FOR ORIGINALLY WRITTEN SOLUTIONS!

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). inputis 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 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.

Programs.

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

Program 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).

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

ENROL WITH ER1731 DIGITAL ELECTRONICS AND PROGRAMMABLE SYSTEMS ASSIGNMENT HELP AND ASSESSMENT WRITING SERVICES OF MIRACLESKILLS.COM AND GET BETTER RESULTS IN ER1731 DIGITAL ELECTRONICS AND PROGRAMMABLE SYSTEMS ASSIGNMENTS!

Searching for cheap and the best online Diploma assignment help services? Chat us. The experts in our team will prepare and deliver plagiarism-free assignment solutions for a minimum price without delay.


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

Lists of comments


Leave a comment


Captcha