By GokiSoft.com|
20:00 18/09/2023|
Lập Trình C
Bài tập - Ôn tập kiến thức từ đầu tới bài học loop trong C - Khóa học lập trình C
Bài 1: Không sử dụng loop -> Yêu cầu tính tổng các số 1 + 2 + .. + N -> Trong đó N nhập từ bàn phím
Bài 2:
Nhập số nguyên N từ bàn phím. Yêu cầu in ra tất cả các ước số chung của N
Bài 3:
Nhập số nguyên num từ bàn phím
In ra bảng cửu chương của num
ví dụ:
num = 5
Kết quả:
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Lưu Trịnh Quyền [community]](https://www.gravatar.com/avatar/630d41f4e7cb673d9a43497c1f2803cc.jpg?s=80&d=mm&r=g)
Lưu Trịnh Quyền
2021-11-26 09:39:08
Bai 3
#include <stdio.h>
int main()
{
int num;
int i;
printf("Nhap gia tri cua N: ");
scanf("%d", &num);
printf("Bang cuu chuong cua %d la: \n", num);
for(i = 1; i < 10; i++)
{
printf("\n %d x %d = %d", num, i, num*i);
}
return 0;
}
![Lưu Trịnh Quyền [community]](https://www.gravatar.com/avatar/630d41f4e7cb673d9a43497c1f2803cc.jpg?s=80&d=mm&r=g)
Lưu Trịnh Quyền
2021-11-26 09:38:53
Bai 2
#include<stdio.h>
int main(int argc, char *argv[]) {
int n, i;
printf("\nNhap gia tri nguyen N:");
scanf("%d",&n);
for(i = 1; i <= n; i++){
if(n%i==0)printf("\nUoc cua n la %d",i);
}
return 0;
}
![Lưu Trịnh Quyền [community]](https://www.gravatar.com/avatar/630d41f4e7cb673d9a43497c1f2803cc.jpg?s=80&d=mm&r=g)
Lưu Trịnh Quyền
2021-11-26 09:38:12
#include<stdio.h>
int main()
{
int n, n1;
int S = 1;
printf("Tinh giai thua N");
fflush(stdin);fflush(stdout);
printf("\nnhap gia tri N ");
fflush(stdin);fflush(stdout);
scanf("%d", &n);
for (n1=1; n1<=n; n1++){
S=S * n;
}
printf("\ngiai thua cua gia tri n = %d", S);
return 0;
}
![Nguyễn Văn Quyết [community]](https://www.gravatar.com/avatar/97724e5c18aa8d264e46cb352482f5a0.jpg?s=80&d=mm&r=g)
Nguyễn Văn Quyết
2021-11-26 09:37:28
bài 123
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(int argc, char *argv[]) {
int n, n1, n2, n3, num, s, i;
int S=1;
printf("bai 1 : Tinh giai thua n!");
fflush(stdin);fflush(stdout);
printf("\nnhap gia tri n ");
fflush(stdin);fflush(stdout);
scanf("%d", &n);
for (n1=1; n1<=n; n1++){
S = S * n1;
}
printf("\ngiai thua cua gia tri n = %d", S);
printf("\nbai 2 : Timm uoc so chung cua N");
fflush(stdin);fflush(stdout);
printf("\nnhap gia tri N ");
fflush(stdin);fflush(stdout);
scanf("%d", &n2);
n3=1;
while(n2 >= n3) {
if(n2 % n3 == 0) {
printf("%d, ", n3);
}
n3 += 1;
}
printf("\nbai 3 : In bang cuu chuong cua num");
fflush(stdin);fflush(stdout);
printf("\nnhap gia tri num ");
fflush(stdin);fflush(stdout);
scanf("%d", &num);
printf("\nbang cuu chuong cua num la :");
for(i=1; i<=10; i++){
s=i * num;
printf(" \n%d * %d = %d",num,i,s);
}
return 0;
}
![vũ bảo nguyên [community]](https://www.gravatar.com/avatar/25ae55431ecb1a0f5eb8bdb798e46fb6.jpg?s=80&d=mm&r=g)
vũ bảo nguyên
2021-11-26 09:25:38
#include "stdio.h"
int main()
{
int c, n, gt= 1;
printf("nhap giai thua can tinh:");
scanf("%d", &n);
for (c=1;c<=n;c++)
gt= gt*c;
printf("\ngiai thua cua %d = %d", n,gt);
return 0;
}
![Student1342918 [community]](https://www.gravatar.com/avatar/a244838ef910ec629f68740828cc0644.jpg?s=80&d=mm&r=g)
Student1342918
2021-11-26 09:24:14
Bài 1 - 2 - 3
#kiemtra2611 1.c
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i,a,n;
n = 1;
i = 1;
printf("\nnhap so giai thua = ");
scanf("%d", &a);
for(i=1; i<=a; i++) {
n = n*i;
}
printf("\ngiai thua cua a = %d", n);
return 0;
}
#uocsochung.c
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n, i;
printf("Nhap so nguyen n: ");
scanf(" %d", &n);
for(i = 1; i <= n; i++){
if(n % i == 0){
printf("%d, ", i);
}
}
return 0;
}
#bangcuuchuong.c
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(void){
int num, i;
printf("Nhap so : ");
scanf(" %d", &num);
for(i = 1; i <= 10; i++){
printf("\n%d * %d = %d", i, num, i*num);
}
return 0;
}
![vũ bảo nguyên [community]](https://www.gravatar.com/avatar/25ae55431ecb1a0f5eb8bdb798e46fb6.jpg?s=80&d=mm&r=g)
vũ bảo nguyên
2021-11-26 09:14:00
#include <stdio.h>
int main() {
int a, num;
printf("Nhap num : ");
scanf("%d", &num);
for(a=1; a<=10; a++)
printf("%d x %d = %d\n", num, a, a*num);
return 0;
}
![vũ bảo nguyên [community]](https://www.gravatar.com/avatar/25ae55431ecb1a0f5eb8bdb798e46fb6.jpg?s=80&d=mm&r=g)
vũ bảo nguyên
2021-11-26 09:12:21
BÀI 2
#include "stdio.h"
int main(int argc, char *argv[]) {
int n,i;
printf("Nhap n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
printf("\nUoc cua n la %d",i);
}
return 0;
}
![Nguyễn Đức Thọ [community]](https://www.gravatar.com/avatar/e131ee83c0279d550c13e1d05530751e.jpg?s=80&d=mm&r=g)
Nguyễn Đức Thọ
2021-11-26 09:09:24
bai 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 main(int argc, char *argv[]) {
int n,i;
do {
printf("\nNhap vao so nguyen n :");
scanf("%d", &n);
if(n<0) {
printf("\nNhap n phai lon hon 0");
}
}while(n<0);
printf("Bang cuu chuong %d\n", n);
for(i=1;i<=10;i++) {
printf("%d * %d = %d\n", n, i, n*i);
}
return 0;
}
![Nguyễn Đức Thọ [community]](https://www.gravatar.com/avatar/e131ee83c0279d550c13e1d05530751e.jpg?s=80&d=mm&r=g)
Nguyễn Đức Thọ
2021-11-26 09:08:21
bai 2
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n,i;
do {
printf("\nNhap vao so nguyen n :");
scanf("%d", &n);
if(n<0) {
printf("\nNhap n phai lon hon 0");
}
}while(n<0);
printf("Bang cuu chuong %d\n", n);
for(i=1;i<=10;i++) {
printf("%d * %d = %d\n", n, i, n*i);
}
return 0;
}