• Ziyaretçi Sayısı:586704
  • www.oguzata.com
  • 18.118.226.105
 !

BF4

Oğuz Ata - BF3 Profili


Facebook

Oguz Ata

Kartınızı Oluşturun



by: Oðuz Ata - 27 Aralık 2013 Cuma 00:16:42

Sınav soruları için Tıklayınız

 

 

3. Soru

#include<stdio.h>
int main(void){
 int side; // length of side
   int rowPosition; // row counter
   int colPosition; // column counter

   printf( "%s", "Enter the square side: " ); // prompt for side length
   scanf( "%d", &side );

   colPosition = side; // set size counter to length of side

   // loop side number of times
   while ( colPosition > 0 ) { 
      rowPosition = side; // set row counter to length of side

      // loop rowPosition number of times
      while ( rowPosition > 0 ) { 

         // if side or row counter is 1 or size print an '*'
         if ( colPosition == side ) {
            printf( "%s", "*" );
         } // end if
         else if ( colPosition == 1 ) {
            printf( "%s", "*" );
         } // end else if
         else if ( rowPosition == 1 ) {
            printf( "%s", "*" );
         } // end else if
         else if ( rowPosition == side ) {
            printf( "%s", "*" );
         } // end else if
         else { // otherwise, print a space
            printf( "%s", " " );
         } // end else

         --rowPosition; // decrement row counter
      } // end inner while

      puts( "" ); // new line for next row
      --colPosition; // decrement size counter
   } // end outer while
	return 0;}

2.Soru


#include<stdio.h>
int main(void){
 double pi = 0.0; // approximated value for pi
   double num = 4.0; // numerator
   double denom = 1.0; // denominator of current term
   unsigned int loop; // loop counter
   unsigned int accuracy; // number of terms

   accuracy = 400000; // set decimal accuracy
   
   // display table headers
   printf( "Accuracy set at: %u\n", accuracy );
   puts( "term\t\t  pi" );

   // loop through each term
   for ( loop = 1; loop <= accuracy; ++loop ) { 

      // if odd-numbered term, add current term
      if ( loop % 2 != 0 ) {
         pi += num / denom;
      } // end if
      else { // if even-numbered term, subtract current term
         pi -= num / denom;
      } // end else

      // display number of terms and approximated 
      // value for pi with 6 digits of precision
      printf( "%u\t\t%f\n", loop, pi );

      denom += 2.0; // update denominator
   } // end for

	return 0;
}

viewed 4583 times -


1 2
Sınav Soruları

Sınav Soruları için tıklatın
(
Son Güncelleme:15.02.2017)




 
 
Oğuz Ata, 2012