Posts

Showing posts from October, 2014

with header file

// ConsoleApplication1.cpp : Defines the entry point for the console application. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { return 0; }

a program

#include<iostream> #include<fstream> using namespace std;       void something(int&); int main(){ int value = 777; } void something(int value){ }

function prototype with header files 9_1

// ConsoleApplication3.cpp : Defines the entry point for the console application. //chapter nine programming challenge 1 //date 10/08/2014 //#include "stdafx.h" #include <iostream> using namespace std; /* int _tmain(int argc, _TCHAR* argv[]) { return 0; } */ //function prototype for functions defined after main function int * arrayAllocator(int); int main(){ int *aryptr=arrayAllocator(10); cout<< aryptr[0] << endl; } int * arrayAllocator(int num){ int * numptr; numptr = new int[num]; numptr[0] = 55; return numptr; }

.cpp array

// ConsoleApplication3.cpp : Defines the entry point for the console application. //chapter nine programming challenge 1 //date 10/08/2014 #include <iostream> using namespace std; //function prototype for functions defined after main function int * arrayAllocator(int); int main(){ int *aryptr=arrayAllocator(10); cout<< aryptr[0] << endl; int fred; cin >> fred; } int * arrayAllocator(int num){ int * numptr; numptr = new int[num]; numptr[0] = 55; return numptr; }

wordcountiterator

#include <iostream> #include <sstream> #include <string> #include <iterator> //http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/ using namespace std; /* int main() { string msg; cout << "Type in a string\n"; getline(cin, msg); istringstream ostr(msg); istream_iterator<string> it(ostr); istream_iterator<string> end; size_t words = 0; while (it++ != end) words++; cout << "\nThere are " << words << " words in this string." << endl; cin.ignore(); return 0; } */

wordcountforloop

#include <iostream> #include <string> using namespace std;   //http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/   /*int main() { int i, numspaces; char nextChar; string msg; numspaces=1; cout << "Type in a string\n"; getline(cin, msg); // checks each character in the string for (i=0; i<int(msg.length()); i++) { nextChar = msg.at(i); // gets a character if (isspace(msg[i])) numspaces++; } cout << "\nThere are " << numspaces << " words in this string."; cin.ignore(); return 0; }*/

stringlengthfrompointer

#include <cstring> #include <iostream> //http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/ using namespace std; // this takes a pointer to a char array and the length of array as params int strlength (char *strx, int size) { int count; for (int x=size-1; x>=0; x--) { count++; if(isspace(strx[x])) { count--; } return count; } } /* int main(){ //define array const int length =30; char name[length]; //prompt for string cout <<"enter a string\n"; cin.getline(name, length); //pass its length and the array as params to function cout << "the number of characters is " <<strlength(name,strlen(name)); cin.ignore(); } */

avgwordlengthfrompointer

#include <iostream> #include <string> using namespace std;   //http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/ /* int main() { int i, numspaces; char nextChar; string msg; numspaces=1; cout << "Type in a string\n"; getline(cin, msg); // checks each character in the string for (i=0; i<int(msg.length()); i++) { nextChar = msg.at(i); // gets a character if (isspace(msg[i])) numspaces++; } cout << "\nIn this string there are about " << (int(msg.length()) - (numspaces-1))/numspaces << " letters in each word."; cin.ignore(); return 0; }*/

reverse from pointer

// this takes a pointer to a char array and the length of array as params //http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/ #include <cstring> #include <iostream>   using namespace std;   void reverse (char *strx, int size) { //loop through array backward and print each character for (int x=size-1; x>=0; x--) cout<<strx[x];   } //define array /* int main() { const int length =30; char name[length]; //prompt for string cout <<"enter a string\n"; cin.getline(name, length); //pass its length and the array as params to function reverse (name,strlen(name));   cin.ignore(); } */

oct 26 in class problem

#include <cstring> #include <iostream> using namespace std;     int strlen (char* strx, int size){ int count; int word; bool space; for (int x=0; x<size;x++) { count++; if(isspace(strx[x])){ count--; if (space==false){ word++;} space=true; } } cout<<"total letters excluding spaces is "<<count<<"/n"; cout<<"number of words "<<word<<"/n"; cout<<"average number of letters per word "<<count/word<<"/n"; }   int main() { //define the array const int length=50; char name[length]; //prompt for the string cout<< "enter a string please"; cin.getline(name, length); //pass its length and the array as params to function strlen (name,strlen(name)); cin.ignore(); }

http://en.wikipedia.org/wiki/African_American

// //http://www.cplusplus.com/doc/tutorial/structures/ // example about structures #include <iostream> #include <string> #include <sstream> using namespace std; struct movie_data { string title; string director; int year; int running_time; } movie1, movie2, movie3; void printmovie (movie_data movie); movie_data make_movie(); int main () { string mystr; movie_data movie1 ={"Aliens","James Cameron",1986,137}; make_movie();   /* cout << "Enter title: "; getline (cin,movie3.title); cout << "Enter director: "; getline (cin,mystr); stringstream(mystr) >> movie3.director; cout << "Enter year: "; getline (cin,mystr); stringstream(mystr) >> movie3.year; cout << "Enter running time: "; getline (cin,mystr); stringstream(mystr) >> movie3.ye...

struct ch 11

we can create functions that are constant and take pointers of structs we create so we aren't passing around values instead of reference types where we can conserve some space c++ we can use a dereference pointer when were manipulating these structs especially when we're printing information and using rerenece function members lets say just to get the structure and then the attributes void getdata(studnt *s) //get the student name cout>> "student name :" cin.getline s-> we also have a datatype called a union where members share a single memory location only one can use at a time but still more are able to use this location so were saving space when we have enumerations we have to access them by identifiers only we can definitely get the integer value when we output from the identifiers and we can compare them but we cant access them by the integers assigne

dynamic web pages final

https://shoppingcartnet.codeplex.com/ http://shoppingcartnet.com/ https://ieonline.microsoft.com/enablesuggestedsites.aspx?ep=ntp Requirements for the ASP.net Final Project   Topic: Create a portfolio/blog/forum about you that could be used for employment purposes Types of pages to be included: Home, Project, Services, Professional Skills, Career History, About Me, Contact Page (Use at least 3 of these)   Basics to be included: Create a site map to link all pages of your website- MUST HAVE a SiteMapPath and either a Menu or TreeView Control Include at least 5 server controls, one bound to a data source on at least one of your pages Include validation controls for all server control inputs that need verification Define master pages and content pages prior to creation to give website a consistent design Master pages and content pages for entire website Two themes to be used in conjunction with Master Pages At least three content pages and at le...

Emerging Technologies

Due Oct 30 by 11:59pm Points 24 Submitting a text entry box Read Chapter 1. On a word document answer the Short Quizzes 1-5 spread throughout the chapter. They are located on page 15 (1-3) , page 23 (1-3), page 33 (1-3), page 45 (1-4) and page 55 (1-2).  Just write down the answers

late to soft 132

Chapter ten number 2 Campus safety in asg Out of pizza solutions for ch10 number 4 from http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/ word counter with iterators #include <iostream> #include <sstream> #include <string> #include <iterator> using namespace std; int main() { string msg; cout << "Type in a string\n"; getline(cin, msg); istringstream ostr(msg); istream_iterator<string> it(ostr); istream_iterator<string> end; size_t words = 0; while (it++ != end) words++; cout << "\nThere are " << words << " words in this string." << endl; return 0; } word counter with for loop #include <iostream> #include <string> using namespace std; int main() { int i, numspaces; char nextChar; string msg; numspaces=1; cout << "Type in a string\n"; getline(cin, msg); // checks each character in the string for...

contiguous

c++ no bounds checking you can use any number for the subscript if you put a constant value as a param for a collection like an array and then allocate more into that object you can later access the indexes out of bounds so this has nothing to do with databases we're managing the memory of our machine during this program a good practice is to use constants and stay within your preferred arrays lets write the pseudo code for linear search if index is equal to value found tru position index end if right at the beginning of chapter ten we see an example of an isspace function in the cstring class

its c string not string

chapter ten then programming challenge 1 three and four take a pointer of a c string and return the length take a pointer and display the content backwards include <cstring> include <iostream> using namespace std; void reverse (char *strx, int sze) { //loop through array backward and print each character for (int size-1 x>=0; x--) cout<<strx[x] } //define array int main(){ const int legth =30; char name[length]; //prompt for string cout "enter a string"; cin.getline(name, length); //pass its length and the array as params to function reverse (name,strlen(name)); int fred; cin>> fred; }

header files are complicated

pointer types are important prototypes must be defined for functions built after the main function // ConsoleApplication3.cpp : Defines the entry point for the console application. //chapter nine programming challenge 1 //date 10/08/2014     #include <iostream> using namespace std; //function prototype for functions defined after main function     int * arrayAllocator( int ); int main(){ int *aryptr=arrayAllocator(10); cout<< aryptr[0] << endl;   int fred; cin >> fred; }   int * arrayAllocator( int num ){ int * numptr; numptr = new int [ num ]; numptr[0] = 55;   return numptr; }

hexadecimals

pointers are cray reference variables are cray arrays are cray http://en.wikipedia.org/wiki/Pointer_(computer_programming ) make a site about boxing and add the modernizer javascript