Home › Forums › C Programming › Please help me › Re: Re: Please help me
November 18, 2008 at 1:15 am
#3478
GWILouisaxwzkla
Participant
3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <br /> /****************************************************************<br /> * File Name : c:programshelptempCG.cpp<br /> * Date : November,17,2008<br /> * Comments : new project<br /> * Compiler/Assembler :<br /> *<br /> *<br /> *<br /> *<br /> *<br /> * Program Shell Generated At: 7:02:58 p.m.<br /> =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /> <br /> <br /> #include < stdio.h ><br /> //#include < string.h ><br /> //#include < conio.h ><br /> //#include < math.h ><br /> //#include < iomanip ><br /> //#include < ctype.h ><br /> #define MAX_LENGTH 50<br /> <br /> <br /> <br /> //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@<br /> <br /> int strLength ( char * );<br /> <br /> //##################################################################################<br /> <br /> <br /> //main function ******************************<br /> <br /> int main ( )<br /> {<br /> <br /> char str [ MAX_LENGTH ];<br /> <br /> printf ( "Enter a string " );<br /> scanf ( "%s" , str );<br /> int lengthStr = strLength ( str );<br /> printf ( "length of string %i n" , lengthStr );<br /> return 0 ;<br /> }<br /> <br /> <br /> /******************************* FUNCTION DEFINITION ******************************<br /> <br /> Name : strLength<br /> Parameters :<br /> <br /> char *<br /> <br /> <br /> Returns: int type<br /> Comments: string must be null terminated<br /> <br /> <br /> <br /> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/<br /> int strLength ( char * str )<br /> {<br /> <br /> int i = 0;<br /> <br /> while ( str [ i ] != 0 )<br /> {<br /> i ++;<br /> }<br /> <br /> <br /> return i;<br /> }<br /> <br /> |
2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <br /> /****************************************************************<br /> * File Name : c:programshelptempCG.cpp<br /> * Date : November,17,2008<br /> * Comments : new project<br /> * Compiler/Assembler :<br /> *<br /> *<br /> *<br /> *<br /> *<br /> * Program Shell Generated At: 7:02:58 p.m.<br /> =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /> <br /> <br /> #include < stdio.h ><br /> //#include < string.h ><br /> //#include < conio.h ><br /> //#include < math.h ><br /> //#include < iomanip ><br /> //#include < ctype.h ><br /> <br /> <br /> <br /> <br /> //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@<br /> <br /> <br /> <br /> //##################################################################################<br /> <br /> <br /> //main function ******************************<br /> <br /> int main ( )<br /> {<br /> <br /> int sLength;<br /> int sum = 0;<br /> int i = 1;<br /> printf ( "Enter length of series " );<br /> scanf ( "%i" , & sLength );<br /> <br /> <br /> while ( i <= sLength )<br /> {<br /> sum = sum + ( i * i * i );<br /> i ++;<br /> }<br /> <br /> printf ( "the sum is %i n " , sum );<br /> <br /> <br /> <br /> <br /> <br /> }<br /> <br /> <br /> |