By GokiSoft.com| 19:11 22/10/2020|
Lập Trình C

[Share Code] Tìm hiểu function trong C - Lập trình C BT2028

#Func.dev


[Project]
FileName=Func.dev
Name=Func
Type=1
Ver=2
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=
Linker=
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
LogOutput=
LogOutputEnabled=0
OverrideOutput=0
OverrideOutputName=
HostApplication=
UseCustomMakefile=0
CustomMakefile=
CommandLine=
Folders=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000000000000000

[VersionInfo]
Major=1
Minor=0
Release=0
Build=0
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0
SyncProduct=1



#test1.c


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

void showMessage() {
	printf("\nHello A");
	printf("\nHello B");
	printf("\nHello C");
}

void tinhtong(int first, int last) {
	int i, tong = 0;
	for(i=first;i<=last;i++) {
		tong+= i;
	}
	printf("\ntong = %d", tong );
}

int tinhtong2(int first, int last) {
	int i, tong = 0;
	for(i=first;i<=last;i++) {
		tong+= i;
	}
	printf("\ntong = %d", tong );
	return tong;
}


#test1.h


void showMessage();
void tinhtong(int first, int last);
int tinhtong2(int first, int last);


Tags:

Liên kết rút gọn:

https://gokisoft.com/2028

Bình luận

avatar
TRẦN VĂN ĐIỆP [Teacher]
2020-10-22 12:35:01



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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void changeValue(int x) {
	x+=2;
	printf("\nx2 = %d", x);
}

void changeValue2(int *x) {
	*x += 2;
	printf("\nx2 = %d", *x);
}

int tinhtong3(int *p, int n) {
	int i, tong = 0;
	for(i=0;i<n;i++) {
		tong+=p[i];
	}
	return tong;
}

int main(int argc, char *argv[]) {
	int x = 5;
	printf("\nx1 = %d", x);
	changeValue2(&x);
	printf("\nx3 = %d", x);
	
	int t[5] = {3, 2, 1, 5, 2};
	int tt = tinhtong3(t, 5);
	
	printf("\nTong: %d", tt);
	
	return 0;
}