== Program 1 == (Basic knowledge of C programming) #include main() { int input; printf("Please input a integer : "); scanf("%d",&input); printf("The number that you input is %d.",input); } == Output == (suppose your input is '1') Please input a integer : 1 The number that you input is 1. ---------------------------------------- == Program 2 == (Basic program of character) #include main() { char a,b,c; printf("Please input your name : "); scanf("%c%c%c",&a,&b,&c); printf("Your name is %c%c%c.",a,b,c); } == Output == (suppose your input is 'Joe') Please input your name : Joe Your name is Joe. ---------------------------------------- == Program 3 == (Basic program of string) #include main() { char input[10]; printf("Please input your name : "); gets(input); printf("Your name is %s.",input); } == Output == (suppose your input is 'Patrick') Please input your name : Patrick Your name is Patrick. ---------------------------------------- == Program 4 == (Basic program of Maths. function) #include #include main() { double a=10,b=4,c=10,d=-10,e=1.2,f=1.8; a = pow(a,2) printf("%lf\n",a); b = sqrt(b); printf("%lf\n",b); c = log(c); printf("%lf\n",c); d = abs(d); printf("%lf\n",d); e = floor(e); printf("%lf\n",e); f = ceil(f); printf("%lf\n",f); } == Output == 100 2 1 10 1 2 ---------------------------------------- == Program 5 == (if..else) #include main() { int input; printf("Please input your marks : "); scanf("%d",&input); if (input>=40) printf("You pass."); else printf("You fail."); } == Output == (suppose you input '50') Please input your marks : 50 You pass. ---------------------------------------- == Program 6 == (while looping) #include main() { int count=0; char name[10]; printf("How many name you want to input? : "); scanf("%d",&count); while (count!=0) { printf("Input your name : "); gets(name); printf("%s\n",name); count = count-1; } } == Output == (suppose your input '2' names) How many name you want to input? : 2 Input your name : Bill Bill Input your name : Gates Gates ---------------------------------------- == Program 7 == (use of string) #include main() { char name[50]; char test[50]; int count=0; printf("Please input your name : "); gets(name); count = strlen(name); printf("Your input contains %d character(s).",count); if (strcmp(name,"Alan")==0) printf("You are Alan."); else printf("You are not Alan."); strcat(name," is the great."); strcpy(test,name); printf("%s",name); printf("%s",test); } == Output == (suppose you input 'Alan') Please input your name : Alan Your input contains 4 characters(s). You are Alan. Alan is the great. Alan is the great.