Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Pointers Examples

Pointers Examples

|Views: 124|Likes:
Published by hozyfa_13
examples on pointers
c++ language
examples on pointers
c++ language

More info:

Categories:Types, School Work
Published by: hozyfa_13 on Apr 03, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Pointers Examples
#include <iostream>#include <cctype>usingnamespace std;int main(){char*p;inti;charstr[80] ="This Is A Test"; cout <<"Original string: "<< str << endl; p = str; // assign p the address of the start of the arrayfor(i =0; p[i]; i++) {// index p if(isupper(p[i])) p[i] = tolower(p[i]);else if(islower(p[i])) p[i] = toupper(p[i]);}cout <<"Inverted-case string: "<< str;return0;}
#include <iostream>usingnamespace std;const intLengh =3; int main (){inttestScore[Lengh] = {4,7,1}; int* intPointer = testScore;for(inti =0; i < Lengh; i++, intPointer++) {cout <<"The address of index "<< i <<" of the array is "<< intPointer << endl;cout <<"The value at index "<< i <<" of the array is "<< *intPointer << endl;}return0;}
#include<iostream>using namespacestd;intmain(){intage[5];int*p;intsum=0,i;charyes='y';p=age;for(i=0;i<5;i++){cout << "Enter the age of a student" << endl;cin >> *p;
sum=sum+*p;p++;}p=age;cout << "The sum of the ages" << sum << endl;\ cout << "The age of the last student is : " << *(p + 4) << endl;return(0);}The result of the program is:-==========================
// rememb-o-matic#include <iostream>#include <new>using namespace std;int main (){int i,n;int * p;cout << "How many numbers would you like to type? ";cin >> i;p= new (nothrow) int[i];if (p == 0)cout << "Error: memory could not be allocated";else{for (n=0; n<i; n++){cout << "Enter number: ";cin >> p[n];}cout << "You have entered: ";for (n=0; n<i; n++)cout << p[n] << ", ";delete[] p;}return 0;}output :How many numbers would you like to type? 5

Activity (9)

You've already reviewed this. Edit your review.
1 hundred reads
phoool liked this
charlie60111 liked this
Abinash Padhi liked this
tushar_sale liked this
Girish Kumar liked this
Girish Kumar liked this
bilal liked this
srivishnu_v liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->