Hi everyone, I have a problem about C programming.
Background Material:
The figure 6 is as below:
The task:
Download the file 55.c. Study the C code, then build an executable and run it to see what the output is. Modify the program so that the output is The string in buffer is "In C the value of 12 + 34 / 5 is 18." Do this by looking up decimal values for ASCII codes in Figure 6 and typing them into the .c file as necessary—in this exercise you’re not allowed to add character constants or string constants to the C code.
The answer:
The printout of complete code of 55.c
Below is the file 55.c:
#include <stdio.h> int main(void) { char buffer[80]; // enough space for a string of length <= 79 // THIS IS A GOOD WAY TO LEARN SOMETHING ABOUT C STRINGS, BUT IT'S // NOT A GOOD EXAMPLE OF READABLE OR PRACTICAL CODE! // Put characters into the string using ASCII codes. buffer[0] = 84; buffer[1] = 104; buffer[2] = 105; buffer[3] = 115; buffer[4] = 32; buffer[5] = 105; buffer[6] = 115; buffer[7] = 32; buffer[8] = 69; buffer[9] = 78; buffer[10] = 67; buffer[11] = 77; buffer[12] = 32; buffer[13] = 51; buffer[14] = 51; buffer[15] = 53; buffer[16] = 33; buffer[17] = 0; // Put the end-of-string character at the end of the string. buffer[17] = 0; printf("The string in buffer is \"%s\"\n", buffer); return 0; }
If you have any doubts, please give me comment...
Output is: The string in buffer is "This is ENCM 335!"
Modified program:
#include <stdio.h>
int main(void)
{
char buffer[80]; // enough space for a string of length <= 79
// THIS IS A GOOD WAY TO LEARN SOMETHING ABOUT C STRINGS, BUT IT'S
// NOT A GOOD EXAMPLE OF READABLE OR PRACTICAL CODE!
// Put characters into the string using ASCII codes.
buffer[0] = 73;
buffer[1] = 110;
buffer[2] = 32;
buffer[3] = 67;
buffer[4] = 32;
buffer[5] = 116;
buffer[6] = 104;
buffer[7] = 101;
buffer[8] = 32;
buffer[9] = 118;
buffer[10] = 97;
buffer[11] = 108;
buffer[12] = 117;
buffer[13] = 101;
buffer[14] = 32;
buffer[15] = 111;
buffer[16] = 102;
buffer[17] = 32;
buffer[18] = 49;
buffer[19] = 50;
buffer[20] = 32;
buffer[21] = 43;
buffer[22] = 32;
buffer[23] = 51;
buffer[24] = 52;
buffer[25] = 32;
buffer[26] = 47;
buffer[27] = 32;
buffer[28] = 53;
buffer[29] = 32;
buffer[30] = 105;
buffer[31] = 115;
buffer[32] = 32;
buffer[33] = 49;
buffer[34] = 56;
buffer[35] = 46;
// Put the end-of-string character at the end of the string.
buffer[36] = 0;
printf("The string in buffer is \"%s\"\n", buffer);
return 0;
}
Hi everyone, I have a problem about C programming. Background Material: The figure 6 is as...
Hi everyone, I have a C programming problem, answers are better
with explanations.
Background Materials:
The Task:
The Answer:
The completed C code.
Below is the file charIO4C.c:
#include <stdio.h>
#include <ctype.h>
#define QUIT_LETTER 'q'
int main(void)
{
int c, line_length;
// Each pass through the outer loop reads a line of input.
while (1) {
printf("\nEnter a line of text. (To quit, start the line with %c.)\n",
QUIT_LETTER);
c = fgetc(stdin);
if (c == EOF || c == QUIT_LETTER)...
Hi, I have C++ programming problem here:
Problem:
Please modify your string type vector in for push_back()
function as below:
void push_back(string str)
{
// increase vector size by one
// initialize the new element with str
}
In addition, the standard library vector doesn't provide
push_front(). Implement
push_front() for your vector. Test your code with the main function
below.
int main()
{
vector v1(3);
cout<<"v1: ";
v1.print(); // this should display -, -, -
for...
C++ please
Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....
In C please : The tasks in this exam review exercise are structured in levels. You can see the point distribution for the levels at the end. It is strongly recommended that you ensure you have passed all test cases of lower levels before moving up to a higher level. For example, ensure you have completed all Level 0 and 1 tasks before even looking at Level 2 Tasks. MESSAGE ENCODER LEVEL 0: (test cases - 50 points) Start by...
C++ Programming
Hi! Sorry for all the material attached. I simply need help in
writing the Facility.cpp file and the other files are included in
case they're needed for understanding. I was able to complete the
mayday.cpp file but am stuck on Facility. The following link
contains a tar file with the files provided by the professor. Thank
you so much in advanced!
http://web.cs.ucdavis.edu/~fgygi/ecs40/homework/hw4/
Closer.h:
#ifndef CLOSER_H
#define CLOSER_H
#include <string>
#include "gcdistance.h"
struct Closer {
const double latitude, longitude;...
I need help finding what is wrong with this code, it is for a CS course I am taking which codes in C (I am using XCode on Mac to code). This is the assignment: "Write a program that performs character processing on 10 characters read in from a file, and writes the results to output files. The program should read from “input.dat”. The program should write the ASCII values of the characters to “output_ascii.dat”. The program should print statistics...
Hi, it's C++ question. Only can use <iostream> and <fstream>libraries Please help me, thanks Question Description: For this project you will write a program to: a) read-in the 10 first names from a file (the file is a priori given to have exactly 10 entries, of a maximum length of 8 letters each) into a 2-dimensional character array, b) output the names to the terminal with each one preceded by a number indicating its original order in the list, c)...
C++ Programming Question: This programming assignment is intended to demonstrate your knowledge of the following: ▪ Writing a while loop ▪ Write functions and calling functions Text Processing [50 points] We would like to demonstrate our ability to control strings and use methods. There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It...
Write in C
Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...