Thứ Hai, 9 tháng 2, 2015

Hàm - chương trình con - function in C (tiếp)


Hàm - chương trình con - function in C (tiếp)



code và chương trình sẵn Tại Đây

1. Write a function which accepts an integer value as input, and returns an integer which is the cube of that input


#include <stdio.h>
#include <stdlib.h>

/* Write a function which accepts an integer value as input, and returns an integer which is the cube of that input */
int l(int);
int main(int argc, char *argv[]) {
 printf("vao X= ");
 int x;
 scanf("%d",&x);
 printf("x^3 = %d",l(x)); 
 printf("\n\n\n");
 system("pause");
 return 0;
}
int l(int x){
 int y = x*x*x;
 return y;
}

lap-phuong
Lập phương


2. Write a function that accepts a char as input and returns true if the char is a digit from 0 to 9 or false if the character is not a digit from 0 to 9



#include <stdio.h>
#include <stdlib.h>
/* Write a function that accepts a char as input and returns true 
if the char is a digit from 0 to 9 or false if the character is not a digit from 0 to 9 */
int tf(char);
int main(int argc, char *argv[]) {
 printf("vao ki tu : ");
 char x;
 scanf("%c",&x);
 if (tf(x)) printf("%c nam giua 0 - 9",x);
  else printf ("%c khong nam giua 0 - 9",x); 
 printf("\n\n\n");
 system("pause");
 return 0;
}
int tf(char x){
 int y;
 if (x >= '0' && x<= '9') y = 1;
 else y = 0;
 return y;
}

tim-kiem
tìm kiếm



#include <stdio.h>
#include <stdlib.h>
/* . Write a function named Smallest that takes three integer inputs 
and returns an integer that is the smallest of the three inputs.  
Write the prototype for the Smallest function.  
Write  a program that gets 3 integers from a user and displays the smallest. */
int m(int,int,int);
int main(int argc, char *argv[]) {
 printf ("vao 3 so : ");
 int x,y,z;
 scanf("%d%d%d",&x,&y,&z);
 printf(" so nho nhat trong 3 so %d %d %d la : %d",x,y,z,m(x,y,z)); 
 printf("\n\n\n");
 system("pause");
 return 0;
}
int m(int x,int y, int z){
 int i =x;
 if (i > y) i = y;
 if (i > z) i = z;
 return i;
}

min
min


4. Write a function that, given a letter of the alphabet, returns true if the letter is a vowel (lower or uppercase) and returns false if the letter is not a vowel.



#include <stdio.h>
#include <stdlib.h>
/* Write a function that, given a letter of the alphabet, 
returns true if the letter is a vowel (lower or uppercase) and returns false if the letter is not a vowel. */
int t(char);
int main(int argc, char *argv[]) {
 printf ("vao 1 chu: ");
 char x;
 gets(&x);
 if (t(x)) printf ("%c la nguyen am",x);
  else printf ("%c khong phai la nguyen am",x);
 printf("\n\n\n");
 system("pause");
 return 0;
}
int t(char x){
 int t;
 if (x=='u'||x=='U'||x=='e'||x=='E'||x=='o'||x=='O'||x=='a'||x=='A'||x=='i'||x=='I') t= 1;
  else t=0;
 return t;
}


tim-nguyen-am
tim nguyên âm


end






















1 nhận xét:

  1. The most enduring symbol of the Norse - titanium arts
    › tj-metal-arts › tj-metal-arts The most enduring symbol of jancasino.com the Norse - titanium arts · The most enduring symbol of the https://tricktactoe.com/ Norse - titanium arts · wooricasinos.info The most enduring symbol titanium metal trim of the Norse https://vannienailor4166blog.blogspot.com/ - titanium arts.

    Trả lờiXóa