Home Forums C Programming Please help me

Viewing 3 reply threads
  • Author
    Posts
    • #2156
      DamarisReagan
      Participant

      1.C prog to find the sum of series 1+(1/3!)-(1/5!)+(1/7!) uptop 20 terms upto 3 decimal places.
      2.C prog to find the sum of cubes of first n integers.
      3.C prog to calculate the length of string without using strlen function.
      4.C prog to read a text file and replace its content in such a way that only one word is found in each line.
      5.Given 3 integers , write a C prog to find the minimum among these by pairwise comparison.
      6.C prog to find the sum of series 1+x-((x^2)/2)+((x^3)/3)-((x^4)/4) upto 20 terms.
      7.C prog to find the sum of series 1+(1/2!)-(1/3!)+(1/4!)-(1/5!)upto first n integers has to be evaluated.
      8.C prog to verify whether a square matrix is symmetric or not .
      9.A text file that stores number of students in a class, one per line exists.Write a C prog to read this file and write it in reverse order.
      10.C prog to print the sum of series S=x-((x^3)/3!)+((x^5)/5!)+((x^7)/7!)+…..n terms

    • #3477
      GWILouisaxwzkla
      Participant

      Do you have a formula for the sum of the first series ( or the name ) ?

    • #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 );





      }


    • #3479
      GWILouisaxwzkla
      Participant

      4.


      /****************************************************************
      * 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 @@@@@@@@@@@@@@@@@@@@@@@@@@



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


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

      int main ( )
      {

      FILE * file1 = fopen ( "c:\programs\data.txt", "r+" );
      FILE * file2 = fopen ( "c:\programs\data2.txt", "w+" );
      char word [ MAX_LENGTH ];

      if( file1 == 0 || file2 == 0 )
      {
      printf( "A file did not open n" );
      return 1;
      }

      fscanf ( file1 , "%s", & word );
      while ( ! feof ( file1 ) )
      {

      fprintf( file2 , word );
      fprintf( file2 , "n" );
      fscanf ( file1 , "%s", & word );
      }
      fclose ( file1 );
      fclose ( file2 );
      return 0;

      }

      5.


      /****************************************************************
      * 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 @@@@@@@@@@@@@@@@@@@@@@@@@@



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


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

      int main ( )
      {

      int one , two , three , smallest;

      printf ( "enter an integer: " );
      scanf ( "%i" , & one );
      printf ( "enter an integer: " );
      scanf ( "%i" , & two );
      printf ( "enter an integer: " );
      scanf ( "%i" , & three );

      if ( one < two )
      smallest = one;
      else
      smallest = two;
      if ( three < smallest )
      smallest = three;

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


      }





Viewing 3 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.