Home Forums C Programming Please help me Re: Re: Please help me

#3478
GWILouisaxwzkla
Participant

3.


/****************************************************************
* File Name : c:programshelptempCG.cpp
* Date : November,17,2008
* Comments : new project
* Compiler/Assembler :
*
*
*
*
*
* Program Shell Generated At: 7:02:58 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include < stdio.h >
//#include < string.h >
//#include < conio.h >
//#include < math.h >
//#include < iomanip >
//#include < ctype.h >
#define MAX_LENGTH 50



//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@

int strLength ( char * );

//##################################################################################


//main function ******************************

int main ( )
{

char str [ MAX_LENGTH ];

printf ( "Enter a string " );
scanf ( "%s" , str );
int lengthStr = strLength ( str );
printf ( "length of string %i n" , lengthStr );
return 0 ;
}


/******************************* FUNCTION DEFINITION ******************************

Name : strLength
Parameters :

char *


Returns: int type
Comments: string must be null terminated



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
int strLength ( char * str )
{

int i = 0;

while ( str [ i ] != 0 )
{
i ++;
}


return i;
}

2.


/****************************************************************
* File Name : c:programshelptempCG.cpp
* Date : November,17,2008
* Comments : new project
* Compiler/Assembler :
*
*
*
*
*
* Program Shell Generated At: 7:02:58 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include < stdio.h >
//#include < string.h >
//#include < conio.h >
//#include < math.h >
//#include < iomanip >
//#include < ctype.h >




//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FUNCTION PROTOTYPES @@@@@@@@@@@@@@@@@@@@@@@@@@



//##################################################################################


//main function ******************************

int main ( )
{

int sLength;
int sum = 0;
int i = 1;
printf ( "Enter length of series " );
scanf ( "%i" , & sLength );


while ( i <= sLength )
{
sum = sum + ( i * i * i );
i ++;
}

printf ( "the sum is %i n " , sum );





}