Annlat
Volki’nin Ağgünlüğü

'Ödev' Kısmı için belgelik

Tasarı (Project) Ödevleri

Salı, Mayıs 27th, 2008

İlk çözümde bizden 2 zarı 36000 kere atmamızı istiyor. Zarı attıktan sonra zarların gelen yüzlerinin toplamını, yüzlerin toplamlarının kaç kere geldiğini ve yüzlerin toplamının yüzdelik olarak ortalaması.. Sorunun esası “C How to Program, Fourth Edition” kitabında sayfa 250 de 6.19. soru..

Çözümde diziler (arrays) kullanıldı.

Programı çalıştırdıktan sonra ekrana okutacağı yazılardan “Face” gelen zarların yüzlerinin toplamı, “Frequency” yüzlerin toplamlarının kaç kere geldiği, “Percentage” yüzdelik..

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

#define SIZE 13

#define MAX 36000

int main() {

int face, roll;

float percentage[SIZE], frequency[ SIZE ] = { 0 };

srand( time( NULL ) );

for ( roll = 1; roll <= MAX; roll++ ) {

face = rand() % 11 + 2;

frequency[ face ]++;

}

for (face = 2 ; face <= 12 ; face++ ) {

percentage[face] = frequency[face] / 360;

}

printf( “%s%17s%17s\n”, “Face”, “Frequency”, “Percentage” );

for ( face = 2; face <= SIZE - 1; face++ )

printf( “%4d %.0f %.2f\n”, face, frequency[face], percentage[face] );

return 0;

}

—————————————————————————————

İkinci çözümde herhangi 20 tane sayı değeri giriyorsunuz. Program girdiğiniz aynı değerlerin toplamı tek ise sonuç olarak gösteriyor.

(more…)

C Programlama Ödevleri

Perşembe, Mart 27th, 2008

Türkçeyi katletme durumundayım çünkü ödev böyleydi. Neyse zaten soruyu anlamıyorsanız ödeviniz değildir. Soruyu anlamasanızda kodları çalıştırarak ne işlev yaptığını görüp, faydalanabilirsiniz.

 

Soru;

4.8 What does this program print?

#include <stdio.h>

/* function main begins program execution */

int main()

{

int x;

int y;

int i;

int j;

/* prompt user for input */

printf( “Enter two integers in the range 1-20: ” );

scanf( “%d%d”, &x, &y ); /* read values for x and y */

for ( i = 1; i <= y; i++ ) { /* count from 1 to y */

for ( j = 1; j <= x; j++ ) { /* count from 1 to x */

printf( “@” ); /* output @ */

} /* end inner for */

printf( “\n” ); /* begin new line */

} /* end outer for */

return 0; /* indicate program ended successfully */

} /* end function main */

Cevap;

When you run the program, it will want to enter two integer in range 1-20. After will add “@”. Your first enter value is line number and second column number.

 

Soru;

 

4.9 Write a program that sums a sequence of integers. Assume that the first integer read with scanf specifies the number of values remaining to be entered. Your program should read only one value each time scanf is executed. A typical input sequence might be

5 100 200 300 400 500

Where the 5 indicates that the subsequent five values are to be summed.

Cevap;

#include <stdio.h>

int main()

{

int num=0;

int num_of_ints=0;

int c=0;

int sum=0;

printf(”Please enter number of integers you will submit:”);

scanf(”%d”,&num_of_ints);

for(c=1;c<=num_of_ints;c++)

{

printf(”Enter Number %i:\n”, num);

scanf(”%d”,&num);

sum = sum + num;

}

printf(”Total of numbers enter: %d\n”,sum);

return 0;

}

 

4.14 The factorial function is used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Write a program that evaluates the factorials of the integers from 1 to 5. Print the results in tabular format. What difficulty might prevent you from calculating the factorial of 20?

Cevap;

#include <iostream.h>

main()

{

#include<stdio.h>

int c(int a);

main()

{

int a;

printf(”Enter a number:”);

scanf(”%d”,&a);

printf(”The factorial number is: “);

printf(”%d”,c(a));

return 0;

}

int c(int a)

{

int b,z;

b=1;

for(z=1;z<=a;z++){

b=b*z;

}

return b;

}

Soru;

5. Consider the function given in Fig. 5.3 (Locate the file fig05_03.c in Book Resources) on page 156 of your textbook. Modify this program so that the program outputs the cube of each input (integer) value. Make all necessary name changes.

/* Fig. 5.3: fig05_03.c
Creating and using a programmer-defined function */
#include <stdio.h>

int square( int y ); /* function prototype */

/* function main begins program execution */
int main( void )
{
int x; /* counter */

/* loop 10 times and calculate and output square of x each time */
for ( x = 1; x <= 10; x++ ) {
printf( “%d “, square( x ) ); /* function call */
} /* end for */

printf( “\n” );

return 0; /* indicates successful termination */

} /* end main */

/* square function definition returns square of parameter */
int square( int y ) /* y is a copy of argument to function */
{
return y * y; /* returns square of y as an int */

} /* end function square */

Cevap;

#include <stdio.h>

int cube( int y ); /* function prototype */

/* function main begins program execution */

int main(void)

{

int x; /* counter */

/* loop 10 times and calculate and output cube of x each time */

for ( x = 1; x <= 10; x++ ) {

printf( “%d “, cube( x ) ); /* function call */

} /* end for */

printf( “\n” );

return 0; /* indicates successful termination */

} /* end main */

/* square function definition returns cube of parameter */

int cube( int y ) /* y is a copy of argument to function */

{

return y * y*y; /* returns cube of y as an int */

} /* end function cube */

Atatürk Sunumu

Çarşamba, Mart 5th, 2008

Bir arkadaşın sunum ödevi için PowerPointin tüm yazı ve resim etkilerini (ingilizcesi effect) kullandık. Hatta 1 den fazla kullandığımız etkilerde oldu. Bunun içinde Atatürkün hayatını ve resimlerini seçtik. Öyle çok bilgi verici özelliği yok sadece sunum ödeviniz varsa işinize yarar.

İNDİR





Tüm hakları saklıdır. İçeriğin büyük kısmı özgün içeriktir. Genelde kopyala-yapıştır içerikli siteler, sitelerinden izinsiz alıntı yapılmasından rahatsız olmaz. Alıntı yaptığım yerlerde kaynağı belirtmek sorumluluğumdur. Lütfen sizde bu sorumluluğa uyunuz. Volki'nin Köşesi 17 sorgu, 0.690 sn gibi bir kısa sürede oluşturuldu :).