SlideShare a Scribd company logo
1 of 11
С++



Энгийн жишээ програм
Энд жишээ болгон дэлгэцэнд Hello World!
гэсэн хэвлэх програм бичье

1:
2:
3:
4:
5:
6:
7:

#include <iostream.h>
#include<stdlib.h>
main()
{
cout<< “Hello World!n”;
system(“pause”);
}
1.
2.

3.
4.
5.
6.
7.

#include<iostream>
#include<stdlib.h>
using namespace std;
main() {
cout << "Hello world!n";
system("pause");
}





Програмын кодыг ойлгоход туслах зорилгоор тайлбар хийнэ.
Энэ хэсэг нь програмын биелэхэд нөлөөлөхгүй. C++ -д
/* тайлбар */ эсвэл
// тайлбар
гэж тайлбар хийдэг.
cout –объект нь дэлгэцэнд
хэрэглэгдэнэ жишээ нь:
1.
2.
3.
4.
5.

6.
7.
8.
9.
10.
11.

12.

өгөгдөл

хэвлэхэд

#include<iostream>//C++ orol garalt
#include<stdlib.h>//C nemelt san jishee
system("pause");
using namespace std;
main() {
cout<< "End 5 baina:"<<5<<"n";
cout<<"Hevshuuleh endl ni shine murnees hevleh
bolomj olgono."<<endl;
cout<<"Ene tom too:t"<<7000<<endl;
cout<<"8+5:tt"<<8+5<<endl;
cout<<"Butarhai too:t"<<(float) 5/8<<endl;
cout<<"mush tom too:t"<< 700*700<<endl;
system("pause");
}
cin>>a; == scanf(“%d”,&a);
cout<<a; == printf(“%d”,a);
А болон В тоог нэмэх програм бич. Гарлт доорох жишээ
1.
2.
3.

4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

#include<iostream>//C++ orol garalt
#include<stdlib.h>//C nemelt san jishee system("pause");
using namespace std;
main() {
int a,b,c;
cout<<"a toog oruul:";
cin>>a;
cout<<"b toog oruul:";
cin>>b;
c=a+b;
cout<<"t a+b="<<c<<endl;
system("pause");
}
Оруулах объект ашигласан жишээ. Нийлбэр олох Add функцын
тусламжтай нэмэх үйлдэл гүйцэтгэх програм
1. #include<iostream.h>
2.
int Add(int x, int y)
3.
{
4.
return (x+y);
5.
}
6.
void main ()
7.
{
8.
int a,b,c;
9.
cout<<”Enter two numbers:”;
10.
cin>>a;
11.
cin>>b;
12.
c=Add(a,b);
13.
cout<<”c:”<<c<<endl;
14.
}
Анхаарал
хандуулсанд
баярлалаа

More Related Content

Similar to Lab1 hylbar program (20)

баяраа сургалт
баяраа сургалтбаяраа сургалт
баяраа сургалт
 
U.cs101 лаборатори 1
U.cs101 лаборатори 1U.cs101 лаборатори 1
U.cs101 лаборатори 1
 
си хэл 10
си хэл 10си хэл 10
си хэл 10
 
C++ суулгах
C++ суулгахC++ суулгах
C++ суулгах
 
бие даалт № 1 borland c++
бие даалт № 1 borland c++бие даалт № 1 borland c++
бие даалт № 1 borland c++
 
Dev c хичээл
Dev c хичээлDev c хичээл
Dev c хичээл
 
203lab1
203lab1203lab1
203lab1
 
Hylbar shugaman programmuud хичээл 4
Hylbar shugaman programmuud хичээл 4Hylbar shugaman programmuud хичээл 4
Hylbar shugaman programmuud хичээл 4
 
с++ хэл
с++ хэлс++ хэл
с++ хэл
 
Ci prog tolgoi file хичээл 2
Ci prog tolgoi file хичээл 2Ci prog tolgoi file хичээл 2
Ci prog tolgoi file хичээл 2
 
Лекц №13
Лекц №13Лекц №13
Лекц №13
 
Ogogdliin sangiin biy daalt
Ogogdliin sangiin biy daaltOgogdliin sangiin biy daalt
Ogogdliin sangiin biy daalt
 
Лекц №8
Лекц №8Лекц №8
Лекц №8
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Давталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогуудДавталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогууд
 
бие даалт
бие даалтбие даалт
бие даалт
 
бие даалт
бие даалтбие даалт
бие даалт
 
1
 1 1
1
 
Flash
FlashFlash
Flash
 

More from Turuu Tsogt (13)

6 shugaman
6 shugaman6 shugaman
6 shugaman
 
5 algorithm
5 algorithm5 algorithm
5 algorithm
 
Lec1 pragraming language
Lec1 pragraming languageLec1 pragraming language
Lec1 pragraming language
 
DBquery
DBqueryDBquery
DBquery
 
DB
DBDB
DB
 
Хүснэгт
ХүснэгтХүснэгт
Хүснэгт
 
C
CC
C
 
Lec8 break
Lec8 breakLec8 break
Lec8 break
 
hicheel2
hicheel2hicheel2
hicheel2
 
hicheel
hicheelhicheel
hicheel
 
Lec5 angi
Lec5 angiLec5 angi
Lec5 angi
 
Lec3 c++operator
Lec3 c++operatorLec3 c++operator
Lec3 c++operator
 
Lec2 c++helnii undeslel
Lec2 c++helnii undeslelLec2 c++helnii undeslel
Lec2 c++helnii undeslel
 

Lab1 hylbar program