Professional Documents
Culture Documents
Network Directory Manual
Network Directory Manual
int main(void ! cout << "#ello$ this is m% &irst '(( )ro*ram+ << endl, return 0, -
int main(void ! dou.le / 0 1.2, int i 0 30, char c 0 4B5, // the &ollo6in* three lines 6or7s &ine: / 0 / ( 28/, // / has the ne6 value 30.2 dou.le % 0 / ( i, // % has the value 31.2 dou.le 9 0 321:2;30<12, // 9 has lar*e ran*e // the &ollo6in* t6o lines is not o7a%: int = 0 / ( i, // can not store dou.le as an int int 7 0 321:2;>?@0321:2;>@0, // ran*e o& 7 is not lar*e enou*h return 0, -
Input/Output
#include <iostream.h> int main(void ! dou.le / 0 0.0, // it5s *ood )ractice to initiali9e all varia.les .% assi*nin* a value cout << "Alease enter a num.er: ", cin >> /, cout << "Bou entered " << / << "$ 6hose sCuare is " << /8/ << endl, return 0, -
Basic Operations
int / 0 30, int % 0 20, int 9 0 (/ ( % 8 (/ D % / (2 8 % E %, // has value 2
Computational S ortcuts
int / 0 30, /((, // / has value 33 / D0 30, // / has value 3, / 80 2, // / has value 2,
!oops
How often do the following loops execute:
&or (int i 0 0, i < 30, i(01 cout << "#o6 o&ten: + << i << endl, int i 0 0, 6hile (i < 30 ! cout << i << endl, i (0 :, -
"unctions
How do you use each of the functions defined below:
void &un3(void ! /8 does somethin* 8/ void &un2(int i ! /8 does somethin* 8/ dou.le &un1(int i$ dou.le / ! /8 does somethin* 8/ -
efine a function that computes the area of a rectangle! "t should not contain any cin or cout statements! efine a function that as#s the user to enter a double number and returns that number!
"f &3 and &2 are defined as above, which of the following calls are invalid:
&3(30$ 20 , &2(10$ :0 , dou.le / 0 30, &3(/$ / , &2(/$ / , &2(30$ / , &2(/$ 30 ,
% 020, void &1(dou.leF 9 ! 9 0 ;0, / 0 >0, int main(void ! dou.le % 0 2, &3(/(% , &2(% , &1(/ D % , &1(/ , cout << "/ 0 " << / << "$ % 0 " << % << endl, return 0, -
&rrays
%! '! )! ,! .! efine an array A of %& doubles! efine an array A of %& doubles and set all of them to %!&( Assume A is an array of * integers! +ind the sum of the first and last entries and assign it to the third element! Write some code segment that prints out an array of doubles of si-e * Write some code segment that multiplies each element of an array by ', storing it bac# in the array!
1!