Gecen donem aldığım bu dersin asistandan ornekleri alıp buraya ekliycem..inşallah işe yarar..
/* Bu benim ilk programim */
#include<stdio.h>
int main(){
printf ("This is my first program.\n"); // comment line
return 0;
}
#include<stdio.h>
int main() {
int a;
float b,c;
a=5;
b=7.6;
c=a+b;
printf("%d + %0.2f = %0.2f\n",a,b,c); /* a,b,c are printed out on the screen */
return 0;
}
#include <stdio.h>
/* This function adds two numbers and returns the result */
float fonk_add( int x, float y ){
float z;
z = x + y;
return z;
}
int main(){
int a;
float b, sum;
a=5;
b=12.50;
sum = fonk_add( a, b); // sum = fonk_add( a, b)=z
printf("The addition of %d and %0.2f is %0.2f\n", a,b,sum);
return 0;
}
#include <stdio.h>
/* This function adds two numbers and prints the result */
void fonk_add( int x, float y ){
float z;
z = x + y;
printf("From the function z = %.2f\n",z) ;
}
int main(){
int a;
float b;
a=5;
b=12.50;
fonk_add( a, b);
return 0;
}
#include <stdio.h>
/* This function prints the message */
void fonk_message(){
printf("This is a message\n") ;
}
int main(){
fonk_message();
return 0;
}
#include <stdio.h>
/* An integer number a is divided by a float number b
numbers a and b are read from the standart input consecutively */
float fonk( int x, float y ){
float z;
z = x / y;
return z;
}
int main(){
int a;
float b, c;
while(1){
printf("Enter two numbers : integer a and float b ? : ");
scanf("%d %f",&a,&b);
c = fonk(a, b); // c = z
printf(" %d / %0.2f = %0.2f \n", a,b,c);
}
return 0;
}
/* 04L01.c: Print out characters */
#include <stdio.h>
int main(){
char c1;
char c2;
c1 = 'A';
c2 = 'a';
printf("Convert the value of c1 to character: %c.\n", c1);
printf("Convert the value of c2 to character: %c.\n", c2);
return 0;
}
/* 04L02.c: Convert numeric values back to characters */
#include <stdio.h>
int main(){
char c1;
char c2;
c1 = 65;
c2 = 97;
printf("The character that has the numeric value of 65 is: %c.\n", c1);
printf("The character that has the numeric value of 97 is: %c.\n", c2);
return 0;
}
/* 04L04.c: Floating-point operations */
#include <stdio.h>
int main(){
int int_num1, int_num2, int_num3, int_num4; /* Declare integer variables */
float flt_num1, flt_num2, flt_num3, flt_num4; /* Declare floating-point variables */
int_num1 = 32 / 10; /* Both divisor and dividend are integers */
flt_num1 = 32 / 10;
int_num2 = 32.0 / 10; /* The divisor is an integer */
flt_num2 = 32.0 / 10;
int_num3 = 32 / 10.0; /* The dividend is an integer */
flt_num3 = 32 / 10.0;
int_num4 = 32.0 / 10.0;
flt_num4 = 32.0 / 10.0;
printf("The integer divis. of 32/10 is: %d\n", int_num1);
printf("The floating-point divis. of 32/10 is: %f\n", flt_num1);
printf("The integer divis. of 32.0/10 is: %d\n", int_num2);
printf("The floating-point divis. of 32.0/10 is: %f\n", flt_num2);
printf("The integer divis. of 32/10.0 is: %d\n", int_num3);
printf("The floating-point divis. of 32/10.0 is: %f\n", flt_num3);
printf("The integer divis. of 32.0 / 10.0 is: %d\n", int_num4);
printf("The floating-point divis. of 32.0 / 10.0 is: %f\n", flt_num4);
return 0;
}


Alıntı ile Cevapla




Bu Konuyu Paylaşın !