C/C++ :: Print To LCD - Count Up To 100 Then Down To 1
Feb 12, 2014
I have the following code to print a string to the LCD using my PIC32 Starter Kit; I have made this code work with success. I cannot, however, make the LCD print numbers.
#include<p32xxxx.h>
#define LCD_PRT PORTE //LCD DATA PORT
//#define LCD_DDR DDRE//LCD DDR
//#define LCD_PIN PINE//LCD PIN
[Code].....
I want to change the original code as little as possible, don't worry about my header files - they are fine.
View 2 Replies
ADVERTISEMENT
Dec 16, 2014
4.1 Write a program that will count from 1 to 12 and print the count, and its square, for each count.
4.2 Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal places for each count. This will require a floating point number.
4.3 Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. Use the incrementing operator for this program.
View 2 Replies
View Related
Sep 27, 2012
Write a count controlled loop than can print "i" char. The user is supposed to input a integer and that integer is how many asterisks there is on the blade, in this case it is 5.
* *
** ** **---------------
*******
** ** **
* ** * -10 Rows high
** -blade always connects on second row of handle
**
**
**
**------------------
These are the steps he told us to do it in.
1) *
**
***
****
*****
2) *
**
***
****
*****
****
***
**
*
3) * *
** **
*** ***
**** ****
**********
4) * *
** **
*** ***
**** ****
**********
**** ****
*** ***
** **
* *
5)* *
** ** **
*******
** ** **
* ** *
**
**
**
**
**
View 4 Replies
View Related
Mar 14, 2013
I have to write a c++ program to read html code and do bunch of stuff. One thing that i have to do is to count the no of attributes and sort them in descenting out and print out only first 10 frequently used attributes. I counted them using maps and sorted them using multimaps but now dnt knw how to print only 10 elements
for(std::map<string, int>::iterator it = Element.begin(); it != Element.end(); ++it)
Elements.insert(pair<int, string>(it->second, it->first));
for(std::multimap<int, string>::reverse_iterator it = Elements.rbegin(); it != Elements.rend(); ++it) {
cout << "Element: " << it->second << " : " << it->first << endl;
}
This is how i did it . How to display only 10 elements and not all the elements.
View 17 Replies
View Related
Apr 9, 2014
write a c++ program that reads an unknown number of integer values and then print count, sum and average of odd values, even values, positive values, negative values!!
View 1 Replies
View Related
Dec 20, 2013
I have written below program to count number of words and lines and print the all the words.
#include <iostream>
using namespace std;
#include<fstream>
#include<string.h>
int main() {
ofstream outfile;
[Code] .....
Its compiling fine but when executed its displaying I infinite times...
View 3 Replies
View Related
Nov 17, 2013
I am making a program where the user enters numbers into an array and then a number,x. The array is sorted, then x is inserted into the appropriate place. I wrote my selection sort
Code:
void Sort(int ary[], int size)
{
int temp;
int smallest;
int current;
int move;
}
[code]....
put it wont print the numbers sorted when I use my print function, just the unsorted numbers.
View 1 Replies
View Related
Sep 1, 2014
is there a to use printf to print certain number of blank spaces, where the number is derived from the output of a function?
for(m=low; m<=high;m++)
{
printf("t=%2d %'f(m)-1's %3c", m, ' ',*);
}
This is suppose to output
t=-3 *
t=-2 *
t=-1
.
.
.
View 2 Replies
View Related
Apr 16, 2013
I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.
Code:
#include <iostream>
using namespace std;
int main()
{
int number[2];
cout << "Enter number: ";
cin >> number[0];
if (number[0] == 1)
[Code] ....
View 11 Replies
View Related
Mar 16, 2013
I'm just trying to find out if the way I've setup my code currently allows me to count the letters as they occur? I don't yet see how to do it but I need clarification. Ideally the function letterCounter would do the counting but atm I'm just trying to figuring it out in the display function.
View 2 Replies
View Related
Mar 16, 2015
i couldn't count the 2d string. my string is list[100][100] = {"Batuhan","Jeyhun","Tashtanbek"} this is a food line in cafeteria. i want to add a person to this list but i couldnt do it because i dont know the length of my list. it will be more than 3 after i add a person but what if i would add another person after that ? In that case i couldnt be able to tell how long is my line.And after i add people to my list i want to print that list. here is where i came so far:
case 1:
printf("Enter the name of the person to be added
");
printf(">>");
k=0;
[Code].....
View 4 Replies
View Related
Jul 12, 2013
I am using this code that to check a set of values from a text file and show it on the output.
Code: void MatchNumber(int b) {
vector<Rect> rects;
ifstream theFile("CheckNumber.txt");
double x1,y1,x2,y2;
while(theFile >> x1 >> y1 >> x2 >> y2 ){
rects.push_back(Rect(x1,y1, x2,y2));
}
int num=0;
[code]....
I want to calculate how many times the common number is repeated . So I have used freq[num] in that function. But I am getting the output like this-
Code:
The common number is = 5
The 5 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times
The common number is = 4
The 4 repeated = 1 times
The common number is = 5
The 5 repeated = 1 times
[code]....
So the freq[num] is only returning 1 instead of counting the total number of repeating which is wrong!! I would like to have somthing like this in my output -
Code:
The common number is = 5
The common number is = 6
The common number is = 4
The common number is = 5
The common number is = 5
The common number is = 8
The common number is = 9
The common number is = 6
The common number is = 6
[code]....
How can I do that?
View 3 Replies
View Related
Oct 2, 2013
a sample program using c language on how to count sentences in a paragraph...
View 3 Replies
View Related
Nov 5, 2014
The question is Create a counting program that counts backward from 100 to 1 in increments of 10.
#include <iostream>
using namespace std;
int main() {
int num = 1;
while (num<100) {
[Code] ....
It seems there are some errors.
View 1 Replies
View Related
Nov 13, 2013
I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B
X = 102
Y = 126
Z = 165
etc...
THAT IS WORNG
The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...
I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
[code].....
View 1 Replies
View Related
Jan 22, 2015
iam trying to count the same numbers in an array just once like
38
38
40
38
40
37
the output should be 2 since 38 is repeated and 40 too but for my code the output is 3 thats an example of how it should be in a nutshell i want same number to be counted just once in the whole array
and here's my code :
#include <iostream>
using namespace std;
int main(){
[Code].....
View 11 Replies
View Related
Mar 7, 2013
I have loaded and 1d array from a .dat file, calculated the average of all the numbers. Now I need to count every number in the array that is below the average and cout that number. This is the method in the class I have so far:
int IntegerArray::countBelowAverage(int numBelowAvg) {
avg=IntegerArray::getAvg();
for(int ct=0; ct<avg; ++ct) {
numBelowAvg=ct;
}
return numBelowAvg;
}
My output from this is always 0 and I know that there are numbers below the avg.
View 2 Replies
View Related
Jun 8, 2013
I was coding a program that can count space, new_line, and other characters in a paragraph, but it doesn't work.
#include <stdio.h>
int main(void)
{
[Code].....
View 1 Replies
View Related
Jun 24, 2014
I have a question regarding reference count of an object. How i'll be able to know that how many pointers are pointing to my object.....
View 3 Replies
View Related
Mar 11, 2013
how to put 2 letters together and make them to count as 1?
provided that they must consecutive
for example:
p : count as 0
pxp : count as 0
pp : count as 1
xpxp: count as 0
ppxpp : count as 2
View 1 Replies
View Related
Nov 6, 2014
I want to count values in a struct.
typedef struct {
int x;
int test;
}TYPE_TEST;
TYPE_TEST My[6] ={
{16, 50},
{4, 51},
{50, 52},
{47, 53},
{10, 54},
{19, 55}
};
int Newbuffer[ ????? ]
Now I want to make the size of Newbuffer the sum of all "x", that is 146. Not the size of X.
But how to sum all "x".
View 5 Replies
View Related
Apr 15, 2014
I am trying to keep a count on a variable name stored within a structure as char*'s. They are of the same field and I do not know how many there will be so I would like to keep a standard name and append the count.
So say I have a variable name such as "desk", but as I have many of these said desks so I would like to call them "desk1", "desk2", "desk3" and so forth. Any recommendations on how I could do this?
Also since this is somewhat relevant is there an easy way to convert from an integer to a string, something that would work like atoi() in reverse? I wouldn't mind writing a method to do so myself but haven't a clue as to how.
View 5 Replies
View Related
Sep 15, 2013
I need a way to count lines in a .dat file using fscanf. I must use a regex to check that the characters in the file are alphanumeric. In essence I need to count the ' ' character. I know fscanf ignores this character. I need to exit if it detects anything other than alphanumeric with the digit that is "problem" along with the line number. My .dat file is:
Code:
howard jim dave
joe
(
Maggie My fileCheck.c is: Code: #include "main.h"
int fileCheck(FILE *fp)
{
int ret_val;
int line_count = 0;
char file[BUFF];
[Code]...
The output I am getting is:
Code:
file opened Digit: ( is not an alphanumeric character on line: 5 Program will exit! File closed As you can see, the character "(" is not on the 5th line but the 3rd. It is the 5th "string."
I also wanted to show the regex I am using.
Code:
#define to_find "^[a-zA-Z0-9]+$"
How this can be accomplished?
View 5 Replies
View Related
Jan 30, 2015
So I already gave this a go and will post my code below. The question is about the last loop before the program cout's. i thought the count would keep track of the repeated numbers so i could display them but it does not. I italicized the loop i am referring to. or at least i tried to xD
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int inputs[30];
int numofloops;
int maxvalue = inputs[0];
[Code]...
View 1 Replies
View Related
Sep 2, 2014
So I made a text file which goes like this
word word word word
word word word word word word word
word word word word word
word word word word
(word is actually word I just didnt type them)
Now i figured out how to get the rows to work
#include <iostream>
#include <fstream>
#include <istream>
#include <stdio.h>
int main()
{
FILE* fp;
int countLines = 1;
int i;
[Code]...
I cant figure out column to work... Is it the same method cause im getting confused a lot!
View 12 Replies
View Related
Jul 14, 2014
In this assignment, you must enter a file and get out of it this:
Summary
Total characters: 8282
Vowels: 2418
Consonants: 3970
Letters: 6388
Digits: 174
Left parentheses: 17
Right parentheses: 17
Single quotes: 17
Double quotes: 14
Other: 1655
Here is my code:
#include <iostream>
#include <fstream>
#include <cctype>
using namespace std;
char ch;
bool isVowel (char);
[Code] .....
View 2 Replies
View Related