Dr Leland Townsend
- 6 Eyl 2017
- 16,496 Mesaj
Aktiflik
Seviye
Deneyim
C PROGRAMLAMA DİLİYLE ÇÖZÜLEN 3 ALGORİTMA SORUSU-
Yukarıdaki gibi bir ekran çıktısı üretebilen bir programı uygun döngü komutlarını kullanarak C programlama dilinde kodlayınız.
Code a program that can produce a screen output like the one above in C programming language using the appropriate loop commands.
Kullanıcı tarafından girilen pozitif bir tam sayıyı asal çarpanlarına ayıran ve ekrana yazan programı C programlama dilinde kodlayınız.
Code the program in C programming language that prime factorizes and displays a positive integer entered by the user.
Doğal logaritma fonksiyonunu hesaplayan programı kodlayınız.
Code the program that calculates the natural logarithm function.
Kod:
a b c d e 6
b c d e 6 5
c d e 6 5 4
d e 6 5 4 3
e 6 5 4 3 2
6 5 4 3 2 1
Yukarıdaki gibi bir ekran çıktısı üretebilen bir programı uygun döngü komutlarını kullanarak C programlama dilinde kodlayınız.
Code a program that can produce a screen output like the one above in C programming language using the appropriate loop commands.
Kod:
#include <stdio.h>
int main() {
int i,j,ch1=65,n,ch2=66,k,p;
printf("please enter number");
scanf("%d",&n);
for(i=1;i<=n;i++){
printf("%c",ch1++);
for(j=n;j>i;j--){
printf("%c",ch2);
ch2++;
}
for(k=n+1;k>n-i+1;k--){
printf("%d",k);
}
printf("\n");
ch2=66+i;
}
for(p=n+1;p>=1;p--){
printf("%d",p);
}
return 0;
}
Kullanıcı tarafından girilen pozitif bir tam sayıyı asal çarpanlarına ayıran ve ekrana yazan programı C programlama dilinde kodlayınız.
Code the program in C programming language that prime factorizes and displays a positive integer entered by the user.
Kod:
#include <stdio.h>
#include <math.h>
void prime_numbers(int a);
int i,n,count=0;
int main()
{
printf("please enter a positive number \n");
scanf("%d",&n);
prime_numbers(n);
return 0;
}
void prime_numbers(int a)
{
for (i = 3;i<=sqrt(n); i = i+2)
{
while (n%i == 0)
{
printf("%d\n",i);
n = n/i;
}
}
/*Sayinin asal carpanlarından biri karekok degerinden buyuk olup donguye girmeyebilirdi
o yüzden bu if koşulunu yazdık ornegin asagidaki kosul olmasaydı 35 sayisinin asal carpanlarından
biri olan 7 sayısı donguye girmeyeceği için program ekrana yazdırmayacaktı*/
if (n > 2)
printf ("%d", n);
}
Doğal logaritma fonksiyonunu hesaplayan programı kodlayınız.
Code the program that calculates the natural logarithm function.
Kod:
#include <stdio.h>
#include <math.h>
int main() {
int i, j;
float result = 0.0f;
float pow;
float x;
printf("please enter a number that you want to calculate ");
scanf("%f", &x);
for (i = 1; i <= 5; i++) {
pow = 1.0f;
/*ln (x) = (x-1)/x + (1/2) ((x-1)/x)^2 + (1/3) ((x-1)/x)^3 +
"ln" formülü bu şekilde de yazılabilmekte.*/
for (j = 1; j <=i; j++) {
pow = pow * ((x - 1.0f) / x);
}
result=result+ (1.0f / i) * pow;
printf("\n result %f\n",result);
}
printf("your input = %f\n result = \n%f", x, result);
return 0;
}
