Question
WRITE C++ PROGRAM FOR THE FOLLOWING TASK WITH EACH PROGRAM BE COMPLETELY RUNNING ON COMPILER AND DO SHOW THE OUTPUT NOTE: THESE THREE PROGRAM ARE
WRITE C++ PROGRAM FOR THE FOLLOWING TASK WITH EACH PROGRAM BE COMPLETELY RUNNING ON COMPILER AND DO SHOW THE OUTPUT
NOTE: THESE THREE PROGRAM ARE THE PARTS OF A TASK OF THE SAME TOPIC DO ANSWER IF YOU COULD SOLVE THE THREE OF THEM
1. Write C++ program to show frequency (count) of each character in the file input_file.txt.The output should show each character once and its count on console. The file contains the following paragraph, copy it and save it in a file input_file.txt.
A few things here. I think its already mentioned - youre not closing the file, this will cause problems.Is the file in ASCII / ANSI encoding? C++ doesnt handle stuff like UTF-8 properly the way youre doing it. So it may count characters wrongly if there are some special multi-byte characters in the file. The way youre going about it is a very convoluted method. Youll be reading that file for each character in your set of characters to test. I.e. youre reading through the entire file 36 times. I think youre missing the point of this exercise - if Id guess its something just after youve learnt about such things as binary search trees and/or hashmaps. If you use these youd only need to read through the file once, and you have the calculations for all chars already. The idea would be to use the char value as key on which to search, the value portion being an integer of how many have already been found.
A sample test:
Input: the five boxing wizards jump quickly
Output:
a=1 b=1 c=1 d=1 e=2 f=1 g=1 h=1 i=4 j=1 k=1 l=1 m=1 n=1 o=1 p=1 q=1 r=1 s=1 t=1 u=2 v=1 w=1 x=1 y=1 z=1
2 ,Given an array of n integers, slope of a line i. e., m and the intercept of the line i.e c, Count the number of ordered pairs(i, j) of points where i ? j, such that point (Ai, Aj) satisfies the line formed with given slope and intercept. Note : The equation of the line is y = mx + c, where m is the slope of the line and c is the intercept.
3. Given three arrays A1, A2 and A3. Write appropriate function that merge these three arrays such that no two A2 elements should be consecutive, element of A1 should not be next to any element of A2, A3 elements can appear alternate. The merged array (new array) must be best sorted.
A1: 32416 A2:
abcdyef A3: 1.1, 12.3, 11.5, 33.6, 1.7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started