본 강의에서는 C언어의 for 반복문에 대해 알아보겠습니다. for 반복문은 반복횟수가 정해져 있을경우 유용한 문장으로, 초기화문과, 조건검사문, 증감문으로 구성되어 조건검사결과가 참이면 주어진 문장을 반복적으로 실행하는 문장입니다.
- Youtube 강의동영상
https://youtu.be/va7vnHThYwA
- 코드는 여기에서 다운 받으세요
https://github.com/dongupak/Basic-C-Programming
본 강좌는 C언어의 문자열을 다루는 함수에 대해서 살펴보겠습니다.
getchar(), putchar()라는 문자열 처리함수는 입력된 문자열에서 Enter키가 들어올 때까지 버퍼에 넣어서 Enter키가 들어오면 버퍼에 있는 문자열을 한꺼번에 처리하는 방식입니다. 반면 MS-DOS 에 포함된 conio.h에 정의된 _getch(), _putch() 함수는 버퍼링을 하지 않고 입력문자를 처리하는 방식입니다.
본 강좌에서는 두가지 방식에 대해서 예제를 통해 살펴보도록 하겠습니다.
- Youtube 강의동영상
https://youtu.be/wOrjr8XprnI
- 코드는 여기에서 다운 받으세요
https://github.com/dongupak/Basic-C-Programming
본 강의에서는 C언어의 for 반복문에 대해 알아보겠습니다. for 반복문은 반복횟수가 정해져 있을경우 유용한 문장으로, 초기화문과, 조건검사문, 증감문으로 구성되어 조건검사결과가 참이면 주어진 문장을 반복적으로 실행하는 문장입니다.
- Youtube 강의동영상
https://youtu.be/va7vnHThYwA
- 코드는 여기에서 다운 받으세요
https://github.com/dongupak/Basic-C-Programming
본 강좌는 C언어의 문자열을 다루는 함수에 대해서 살펴보겠습니다.
getchar(), putchar()라는 문자열 처리함수는 입력된 문자열에서 Enter키가 들어올 때까지 버퍼에 넣어서 Enter키가 들어오면 버퍼에 있는 문자열을 한꺼번에 처리하는 방식입니다. 반면 MS-DOS 에 포함된 conio.h에 정의된 _getch(), _putch() 함수는 버퍼링을 하지 않고 입력문자를 처리하는 방식입니다.
본 강좌에서는 두가지 방식에 대해서 예제를 통해 살펴보도록 하겠습니다.
- Youtube 강의동영상
https://youtu.be/wOrjr8XprnI
- 코드는 여기에서 다운 받으세요
https://github.com/dongupak/Basic-C-Programming
1. For
1_Sumar 20 numeros
#include <iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int main (){
int num,control;
num=1;
for(int control=1;control<=20;control++);
{
cout<<control<<endl;
}
getch();
return 0;
}
3. Dos números ------------------------------------for
#include <iostream>
#include<stdlib.h>
#include<string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int main(){
int control,num1;
for(control=1;control<=10;control++)
{
cout<<"num1"<<endl;
num1=num1+2;
}
system("pause");
return 0;
}
4. Tablas de multiplicar -----------------------------for
#include <iostream>
#include<stdlib.h>
#include<string>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int main(){
int control,numero,resultado;
control=1;
numero=1;
do
{
resultado=control*numero;
cout<<numero<<"*"<<control<<"="<<resultado<<endl;
control++;
}
while(control<=10);
system("pause");
return 0;
}
5. Números pares -----------------------------for
#include <iostream>
#include<stdlib.h>
#include<string>
using namespace std;
int main()
{
int num,control,n;
n=0;
for(control=1;control<=10;control++)
{
cout<<n<<endl;
n=n+2;
}
system("pause");
return 0;
}