(main.c File)
Counting the character occurrences in a file
For this task you are asked to write a program that will open a file called “story.txt”
and count the number of occurrences of each letter from the alphabet in this file.
At the end your program will output the following report:
Number of occurrences for the alphabets:
a was used – times.
b was used – times.
c was used – times…. …and so, on
Assume the file contains only lower-case letters and for simplicity just a single
paragraph. Your program should keep a counter associated with each letter of the
alphabet (26 counters) [Hint: Use array]
Your program should also print a histogram of characters count by adding
a new function print Histogram (int counters []). This function receives the
counters from the previous task and instead of printing the number of times each
character was used, prints a histogram of the counters. An example histogram for
three letters is shown below) [Hint: Use the extended asci character 254]
Answer:
C code
Explanation:
#include <stdio.h>
void histrogram(int counters[])
{
int i,j;
int count;
for(i=0;i<26;i++)
{
count=counters[i];
printf("%c ",i+97);
for(j=0;j<count;j++)
{
printf("="); //= is used
}
printf("\n");
}
}
int main()
{
FILE* fp;
int i;
int arr[26];
char c;
int val;
// Open the file
fp = fopen("story.txt", "r");
if (fp == NULL) {
printf("Could not open file ");
return 0;
}
else
{
for(i=0;i<26;i++)
arr[i]=0;
for (c = getc(fp); c != EOF; c = getc(fp))
{
if(c>='a' && c<='z')
{
val = c-97;
//printf("%d ",val);
arr[val]++;
}
}
histrogram(arr);
}
}
I need help
I am thinking about coming out to my mom because we are going to the store today and I will be in the car, I dont know if I should or not
Answer:
do it! you will have to one day so why not now? hopefully she will understand and say nice things as well and be like mom ive
been thinking a lot and i really want to tell you something. Explanation:
Answer:most likely she is your parent that you live with so she might already know but has not said anything it also depends her personality but if your ready and know or think she would not hate you forever go for it
Explanation:
Mohammed needs to ensure that users can execute a query against a table but provide different values to the query each time it is run. Which option will achieve this goal?
parameter queries
dynamic queries
query joins
static queries
Answer:
the answer is B
Explanation:
The Basic premise of____is that objects can be tagged, tracked, and monitored through a local network, or across the Internet.
The basic premise of
a. artificial intelligence
b. intelligent workspaces
c. the Internet of Things
d. the digital divide
Answer:
C.
Explanation:
Internet of things
The Basic premise of the Internet of Things is that objects can be tagged, tracked, and monitored through a local network, or across the Internet option (c) is correct.
What is IoT?The term "Internet of things" refers to actual physical items that have sensors, computing power, software, and other innovations and can link to those other systems and gadgets via the Internet or other communication networks and share files with them.
As we know,
Using a local network or the Internet, things may be identified, tracked, and monitored is the fundamental tenet of the Internet of Things.
Thus, the Basic premise of the Internet of Things is that objects can be tagged, tracked, and monitored through a local network, or across the Internet option (c) is correct.
Learn more about the IoT here:
https://brainly.com/question/25703804
#SPJ2
Two character strings may have many common substrings. Substrings are required to be contiguous in the original string. For example, photograph and tomography have several common substrings of length one (i.e., single letters), and common substrings ph, to, and ograph as well as all the substrings of ograph. The maximum common substring length is 6. Let X = X122 . Im and Y = yıy2 - - • Yn be two character strings. Using dynamic programming, design an algorithm to find the maximum common substring length for X and Y using dynamic programming. Please follow the general steps for designing a dynamic programming solution as in Q1 (other than the actual programming part).
Answer:
Explanation:
The following function is written in Java. It takes two strings as parameters and calculates the longest substring between both of them and returns that substring length.
import java.util.*;
class Test
{
public static void main(String[] args)
{
String X = "photograph";
String Y = "tomography";
System.out.println(X + '\n' + Y);
System.out.println("Longest common substring length: " + longestSub(X, Y));
}
static int longestSub(String X, String Y)
{
char[] word1 = X.toCharArray();
char[] word2 = Y.toCharArray();
int length1 = X.length();
int length2 = Y.length();
int substringArray[][] = new int[length1 + 1][length2 + 1];
int longestSubstringLength = 0;
for (int i = 0; i <= length1; i++)
{
for (int j = 0; j <= length2; j++)
{
if (i == 0 || j == 0)
substringArray[i][j] = 0;
else if (word1[i - 1] == word2[j - 1])
{
substringArray[i][j]
= substringArray[i - 1][j - 1] + 1;
longestSubstringLength = Integer.max(longestSubstringLength,
substringArray[i][j]);
}
else
substringArray[i][j] = 0;
}
}
return longestSubstringLength;
}
}
The variable strFirst's scope is _____.
Answer:
- the usernameMaker function
Explanation:
When you look at the code, you can see it's located alongside the usernameMaker. It it only utilized then, therefore being it's scope. For reassurance, it's also correct on Edge.
I hope this helped!
Good luck <3
14. Video game legend Shigeru Miyamoto designed all EXCEPT which of the following games?
a) Donkey Kong
b) Mario Bros
c) The Legend of Zelda
d) Pac-Man
Taran is concerned with the security of his macros in a database. Which security option could he use to provide protection?
digital signatures
hide database objects
start-up options
secure VBA code
Answer:security VBA code
Explanation:
Sergio needs to tell his team about some negative feedback from a client. The team has been
working hard on this project, so the feedback may upset them. Which of the following explains
the best way for Sergio to communicate this information?
A) Hold an in person meeting so that he can gauge the team's body language to assess their
reaction
B) Send a memorandum so everyone will have the feedback in writing
C) Hold a video conference so everyone can see and hear about the client's concern without the group witnessing each other's reactions
D) Send an email so everyone will have time to think about the feedback before the next team meeting
Answer:
A
Explanation:
I feel that if everyone is with eachother, there may be a better hope to improve the next time
Write an algorithm (pseudo-code) that takes an unsorted list of n integers and outputs a sorted list of all duplicate integers. There must be no duplicates in the output list, also the output list should be a sorted list. The algorithm must run in O(n) time. Show your analysis of the running time. Note: Assume that inputs are integer values from 0 to 255. (Hint: use the concept that being used in the separate chaining)
Answer:
brainliest if it did help you
Explanation:
Given array : A[0...n-1]Now, create a count array Cnt[0...n-1]then, initialize Cnt to zero
for(i=0...n-1)
Cnt[i]=0 ---------O(n) time
Linearly traverse the list and increment the count of respected number in count array.
for(i=0...n-1)
Cnt[A[i]]++; ---------O(n) time
Check in the count array if duplicates exist.
for(i=0...n-1){
if(C[i]>1)
output (i); -----------O(n) time
}
analysis of the above algorithm:
Algorithm takes = O(1 + n + n + n)
= O(n)
//java code
public class SortIntegers {
public static void sort(int[] arr) {
int min = arr[0];
int max = arr[0];
for (int i = 0; i < arr.length; ++i) {
if (arr[i] > max) {
max = arr[i];
}
if (arr[i] < min) {
min = arr[i];
}
}
int counts[] = new int[max - min + 1];
for (int i = 0; i < arr.length; ++i) {
counts[arr[i] - min]++;
}
for (int i = 0; i < counts.length; ++i) {
if (counts[i] > 1) {
System.out.print((i + min) + " ");
}
}
System.out.println();
}
public static void main(String[] args) {
sort(new int[] { 5, 4, 10, 2, 4, 10, 5, 3, 1 });
}
}
The following table describes the required fields for two classes and typical values stored in those fields.
You are required to create a base class Printer and its child class PrinterCumScanner. Each of these classes should have user defined constructor and overridden Display() method so that the following test driver can work properly.
Answer:
hope this helps,if it did pls mark my ans as brainliest
Explanation:
using System;
class Printer{ string companyName; int pagesOutput;
double price;
public Printer(string companyName,int pagesOutput,double price){
this.companyName=companyName; this.pagesOutput=pagesOutput; this.price=price;
}
public virtual void Display(){ Console.WriteLine("companyName: "+companyName+" pagesOutput: "+pagesOutput+" price: "+price);
}
}
class PrinterCumScanner:Printer{ int imageDpi;
public PrinterCumScanner(string companyName,int pagesOutput,double price,int imageDpi):base(companyName,pagesOutput,price){ this.imageDpi=imageDpi; }
public override void Display(){ base.Display(); Console.WriteLine("imageDpi: "+imageDpi);
}
}
public class Program { static void Main(string[] args) { const int NUM_PRINTERS=3;
Printer []stock=new Printer[NUM_PRINTERS];
stock[0]=new Printer("HP",40,89.50);
stock[1]=new PrinterCumScanner("HP",40,215.0,320); stock[2]=new PrinterCumScanner("Cannon",30,175.0,240);
foreach(Printer aPrinter in stock){ aPrinter.Display();
}
}
}
What does getfenv() do?
Answer: getfenv() is a type of function. Particually a envirotment function. for a lua coding.
Explanation: What this does it goes thourgh line of code in a particular order.
This means. getfenv is used to get the current environment of a function. It returns a table of all the things that function has access to. You can also set the environment of a function to another environment.
Forgot to include examples of where this could be used. Although not very common uses, there are some. In the past Script Builders used getfenv to get the environment of a script, and setfenv to set the environment of a created script’s environment to a fake environment, so they couldn’t affect the real one. They could also inject custom global functions.
Not entirely sure if this uses getfenv or setfenv, but the use in Crazyman32’s AeroGameFramework is making the environment of each module have access to other modules without having to require them, and having access to remotes without having to directly reference them.
Answer: ummm, who knows
Explanation:
Which tab can be used to change the theme and background style of a presentation?
O Design
O Home
O Insert
O View
Answer:
Design
Explanation:
seems the most correct one..
A major advantage of direct mapped cache is its simplicity and ease of implementation. The main disadvantage of direct mapped cache is: a. it is more expensive than fully associative and set associative mapping. b. it has a greater access time than any other method. c. its performance is degraded if two or more blocks that map to the same location are used alternately. d. it does not allow the cache to store the tag that corresponds to the block currently residing in that cache location.
brainlest pl jk mmmmmmmmmmmmm