Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Test Coming Up

ascii value

  • Please log in to reply
6 replies to this topic

#1 Hydrokr0n1k


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 57 posts
  • Learning:C++, JavaScript

Posted 19 April 2012 - 01:35 PM

ok lol I have a test coming up and I am supposed to sit in the classroom and code this out on paper I think
I have a week or so till I have to be in there but they are going to want to know I cna calulate real and integer divides and what now this the Review he gave us any tips and help would be grately appreciated

Sample CS181 final Review
1. Write a function that accepts a two dimensional integer array and returns a Boolean indicating whether the array contains any duplicate numbers. Consider the following array:

1 3 4 5
4 6 7 9
1 6 5 0

the numbers 3, 7, 9, and 0 occur only once, so the function would return 4.
2. Write a function goo that accepts a two dimensional array x of strings and counts the number of characters in each string in that array that are >= ‘a’ and <=’f’. Thus if x contains:

cat bat foo zork
boo at zoo ate then goo(x, gooRowSize, gooColSize) would return 9.

3. Write a function that accepts a one dimensional array of strings and returns the sum of the ascii values of the characters in all the strings.

4. Write a function that returns the average of the first 100 positive integers (starting at zero) that are divisible by three.
  • 0

#2 DarkLordCthulhu


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 422 posts
  • Location:The bash shell
  • Programming Language:C, JavaScript, Bash, Others
  • Learning:Ruby, Others

Posted 19 April 2012 - 01:54 PM

We're not going to do your homework for you. Stop bumping down my thread.
  • 0
Programming is a journey, not a destination.

#3 papabear


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 19 April 2012 - 01:56 PM

Hello HK threethousandeight, the code for those are simple.. before we can help you, you must provide some snippet of codes or codes that you have tried
or show us some effort and then we can help you solving your errors, because we want that everybody will learn :) I suggest that you must try it first..

1. my solution for this is to create a 2 nested loop.. the main loop will maybe handle the other value and the inner loop will handle another value from the array and then I'm going to compare the two value inside the inner loop maybe something like this

for i = 0 ; i<arraylength; i++
	 for j = i+1; j<arraylength; j++
		   if array[i] == array[j] then
				 return array[i]
		   end the if
	 end for
end for

maybe something like that :) that is not the correct syntax and code for C/C++ I just gave you an idea.. if you want us to give you more idea for the other numbers.. you must show us some effort of doing it :)
  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#4 Hydrokr0n1k


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 57 posts
  • Learning:C++, JavaScript

Posted 23 April 2012 - 08:31 PM

Well its just a review sheet I have not sat down to start any of it as its just a final review typically I allways post a portion if not all of my completed code on a project looking for insight and debugging efforts but I did think about how to really go about this review
but this would be my solution for 2 probably
//C program to accept a string from user and
//display its ascii value and
//then display sum of all ascii value of strings
#include <string.h>
int main() {
char String[100];
int Sum,Index;
Sum=0; //Sum is initially zero
printf("Enter the string:\n");
gets(String); //Accept String from User
Sum+=(String[Index]); //Adds (the ASCII values of) the String characters.
printf("The sum is %d\n",Sum); //Printing it as %d gives the equivalent ASCII value.
return 0;

How does he expect us to do this in class tho I am baffled these projects take me hours at home per function and here he is gonna throw 4 at us to do on paper :(

We're not going to do your homework for you. Stop bumping down my thread.

Sorry its not home work Dark Penguin its a Review other wise I would have posted my part in it and My apologies if I bumped your thread down it was not my intentions :) I get on here and get to typing code and home work assignments and next thing you know I am going a million words per hour lol not really it just seems like I have alot to get out there but I will try to pace my questions better I just really want knowledge lol fast haha I just dont think I comprehend it fast enough or can din it but off topic I am very sorry again :)
  • 0

#5 notes


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 88 posts
  • Location:Poland
  • Programming Language:C++
  • Learning:Java, C#

Posted 24 April 2012 - 01:07 AM

There are few errors I cant understand in exercises.
1. You have to write function that returns boolean value ( true or false )and then it says that function will have to return some integer .... ?
2. I cant understand this task at all.. :/

As for your code. I suggest you try to put it in a function. Making class out of this few lines of code is pointless for me cause your class shall have string, int variable and one method...
Here is how I made function out of your code..
// main.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int ascii_sum(char char_arr[]);
int _tmain(int argc, _TCHAR* argv[])
char my_arr[100];
cin >> my_arr;
cout << endl << ascii_sum(my_arr) << endl;

return 0;
int ascii_sum(char char_arr[]) {
int size = strlen(char_arr);
int sum = 0;
for ( int i = 0 ; i < size ; i++) {
  cout << (int)char_arr[i] << " ";
cout << endl << "Sum :";
return sum;

Hope this helps.
  • 1
Remebre about KISS & DRY

#6 FuckDavidBeard


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 29 April 2012 - 10:07 AM

I'm in the same class as this guy (google brought this up when i searched for solutions to the practice exam). the prof in this class talks more about the history of klingons and beethoven and how to write code in different langauges more than he talks about c++. the first three functions are way beyond what i can do at this point (the first one simply because what he asks us to do and the return value he gives don't agree with each other)

p.s. if you couldn't tell the profs name is david beard
  • 0

#7 Hydrokr0n1k


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 57 posts
  • Learning:C++, JavaScript

Posted 29 April 2012 - 02:25 PM

what I do not understand is how he could expect us to do all this in a matter of an hour or two in class just seems a little far fetched even for an expert programmer
  • 0

Also tagged with one or more of these keywords: ascii value

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download