0% found this document useful (0 votes)
51 views7 pages

C++ Basic Programs

complete C++ notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
51 views7 pages

C++ Basic Programs

complete C++ notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
1]. [Ergonaccr series in c++ => st include using namespace std int main) int m1, n2,n3, i, number n=O 5 n2.= 1) a =f me Cout "<< entey -the numbey of elements: > Cin >> number 5 cour<< nicenz<<* "+ I] fyinting Of | for Ci=24 ic number; i+r) n3= n+ nz Cour<é Ngee n= nz; n2 2b seturn_O 5 Output +-_enter the numbey_of element 10 ONG OTES VEE) eel. PRIME _lomBe! OLRAM IN Ct + include < jostreaqm > using namespace std} int main (_) _clhssoate. Le int n, i, m=o, Flag= 0; Cout << “entey number to check prime +" 3 Cin >>n;5 MF n125 for(i=a; ic=m; i+t) ieCny-i ==0) -f Cout <<“ number js not prime”: < By veturn 0% LET Output + enter a number to check prime + 20 number is not prime- *_entey a number to cherie pyime + 13 nuMber is prime. 2]. LPALINDRomE NumBER IN C+ =P “Tne palindyome number is same after xeverse - Example 121, 32123 , 2392432 — __4F include | using namespace std 5 | int main (_) int nv, sum=o , temp; cout << “enter the number =" 5 Cin >>n5 temp=n: while (n > 0 ) a BEN 105 sum=( sum x 10) +45 n= n1/10 if (temp == sum __ ) cout << “ numbey is palindyome.” 5 else a Cout <<“ numbey is not palindyome.”; yeturn Oj ee : + aes Output - e entey the number = 12321 number is Palindyome. © enter the number =120 number is not Patindyome . Pa — AF include Using namespace std y int main ¢_) int i, fact, number; . « Ws cout <<" enter any numbey + > Cin >> number; ep | for(ici; < = number 5 itt) ¢ fact = fact * is ¥ cout <<“ Factorial of " << numbey << fs +” << Fact << endl 5 yeturn Oo; Output'-_entey any number : 5 Factorial of. 5 is +120. at include ciostream> using namespace std 5 tnt main C) int: a2 86 poe cout <<“ Before swap a= +t include ciostxeam > using namespace stds int main C ) Thtt nous, i) Coute< “ entex the number of yous +.” 5 Cine > snes for (i = 3 |, 1 ¢ Sie eae) fos (QS hige)< = epaoe ee ee Couttccéae ok ae Cout <<“ \n_ seturn 05 entey numbey yows aoe) => 4# include using namespace std 5 int main () Int yous i 3 spaces , cout<<" entey number yows:” 3 Cin >> yows 5 for (=i, 1e=yows s i++) fox (Spaces =i ; spaces < vows 5 Spaces ++) Cout <<“ 3 For ( at include using namespace std 5 int mainC ) Int n,Sum=O,m; cout <<“ entey q number 2"5, Cin>>ane while (n> 0) IM SSS ae) Sum = SU nN=n/lo5 uk Cour<< “sum is = "ee sume< endl; seturn oO + > et put:— 2 —_entex O number = 55 Sumis 10=

You might also like