1. Write a function which accepts an integer value as input, and returns an integer which is the cube of that input
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
3. 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.
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.
Bài LàmBài 1
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int LapPhuong(int );
int main(int argc, char *argv[]) {
int A;
printf("Nhap So :");
scanf("%d",&A);
printf("Lap Phuong = %d",LapPhuong(A));
return 0;
}
int LapPhuong(int A){
int t;
t= A*A*A;
return t;
}
Bài 2
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
char A(char );
int main(int argc, char *argv[]) {
char B;
printf("Nhap Mot Ki Tu :");
scanf("%c",&B);
if(B>='0'&&B<='9') {
printf("True");
}
else printf("False");
return 0;
}
char A(char B ){
if(B>=0&&B<=9)
return B;
}
Bài 3.
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int A(int,int,int );
int main(int argc, char *argv[]) {
int a,b,c;
printf("Nhap So :");
scanf("%d",&a);
printf("Nhap So :");
scanf("%d",&b);
printf("Nhap So :");
scanf("%d",&c);
printf("So nho nhat trong 3 So la :%d",A(a,b,c));
return 0;
}
int A(int a,int b, int c ){
int i=a;
if(i>b) i=b;
if(i>c) i=c;
return i;
}
Bài 4
#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 N(char);
int main(int argc, char *argv[]) {
char x;
printf ("Nhap Chu: ");
scanf("%c",&x);
if (N(x)) printf ("%c =Nguyen Am",x);
else printf ("%c K lA Nguyen Am",x);
return 0;
}
int N(char x){
int N;
if (x=='u'||x=='U'||x=='e'||x=='E'||x=='o'||x=='O'||x=='a'||x=='A'||x=='i'||x=='I') N= 1;
else N=0;
return N;
}




Không có nhận xét nào:
Đăng nhận xét