IT STUDENT
Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Viết chương trình nhập vào một số và in ra tổng tất cả các số từ 1 tới số đó

Go down  Message [Page 1 of 1]

Admin


Admin

Code:
#include<stdio.h>
#include<conio.h>
// viet chuong trinh nhap vao mot so va tinh tong tat ca cac so tu 1 toi so do
int nhap(){
int n;
printf("nhap vao so n:");
scanf("%d:",&n);
return n;
}
int tinhtong(int n){
int tong=0;
int i;
for(i=1;i<=n;i++){
tong+=i;
}
return tong;
}
int main(){
int a,s;
a=nhap();
s=tinhtong(a);
printf("tong la:%d",s);
getch();
}

https://itstudent-pnv.board-directory.net

Admin


Admin

hay

https://itstudent-pnv.board-directory.net

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum