Forum Rules Today's Posts Mark Forums Read Social Groups Donate
Go Back   PinoyXtreme > PX Technology > Programming Related > C/C++/C++.NET

Reminders on Coding Sections





Reply
 
Thread Tools
Old 07-25-2012, 11:06 PM   #1
[TUT] C++/C# Sample Codes
Primera Primera is offline 07-25-2012, 11:06 PM

c Code:
#include<iostream.h> #include<string.h> #include<stdlib.h> #include<stdio.h> void main() { char fn[50],sn[50],ans; int age;         top: system("cls"); cout<<"\n\nEnter your first name: "; cin>>fn; cout<<"\nEnter your surname: "; cin>>sn; [Only Registered Users Can See LinksClick Here To Register] <<"\nEnter your age: "; cin>>age; [Only Registered Users Can See LinksClick Here To Register] <<"\n\n\n";     if (age>=18)                 [Only Registered Users Can See LinksClick Here To Register] <<fn <<" "<<sn <<" you are qualified to vote.\n";     else         [Only Registered Users Can See LinksClick Here To Register] <<fn <<" "<<sn <<" you are not qualified to vote.\n"; here:         cout<<"\n\n\n\n\n\nEnter another data? [Y]-Yes or [N]-No: ";         cin>>ans;         cout<<endl<<endl<<endl;         if (ans == 'n'|| ans == 'N'){           exit;}         else if (ans == 'y' || ans == 'Y'){         goto top;}         else         {         cout<<"Invalid input"<<endl;         goto here;         } }

 
Primera's Avatar
Primera
Unknown Boy
Join Date: Apr 2010
Location: Secret Place
Posts: 617



Views: 415
Reply With Quote
The Following 2 Users Say Thank You to Primera For This Useful Post:

 Re: [TUT] C++/C# Sample Codes
Old 09-16-2012, 01:02 AM   #2
 
Primera's Avatar

Primera
Unknown Boy
Primera is offline
Posts: 617
PX Cash: 10,120
Primera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to behold
Rep Power: 194
Default Re: [TUT] C++/C# Sample Codes

Sample Program Using "function" to compute the factorial of a number.

c Code:
#include<iostream.h> #include<conio.h> int factorial (int);     //function declaration int main() {         int num, f;         cout<<"Enter a number: ";         cin>>num;         f = factorial(num);     //function calling         cout<<endl;         cout<<"The factorial of "<<num<<" is "<<f<<endl<<endl;         getch();         return 0; } int factorial(int num)     //Start of function definition {         int F = 1;         for(int ctr = 1; ctr<=num; ctr++)         {                 F=F*ctr;         }         return F; }



Note:
C code is compiled and run using Dev C++ 4.9.9.2
  Reply With Quote

 Re: [TUT] C++/C# Sample Codes
Old 09-16-2012, 11:02 AM   #3
 
Primera's Avatar

Primera
Unknown Boy
Primera is offline
Posts: 617
PX Cash: 10,120
Primera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to beholdPrimera is a splendid one to behold
Rep Power: 194
Default Re: [TUT] C++/C# Sample Codes

Sample C Code that input 5 Quizzes grade using "Array"

c Code:
#include<iostream.h> void main() {         int const max = 5;         int score[5];                 for (int j=0; j<max; j++)         {                 cout<<"Enter score of quiz "<<j+1<<": ";                 cin>>score[j];         }         cout<<"\n\nYour quiz scores are: "<<endl;         for (int m=0; m<max; m++)         {                 cout<<"Score of quiz "<<m+1<<": "<<score[m]<<endl;         }         cout<<endl<<endl; }


Note:
Compiled, Build, and Run using Visual C++ 6.0
  Reply With Quote

 Re: [TUT] C++/C# Sample Codes
Old 03-27-2013, 10:42 PM   #4
 
kepper's Avatar

kepper
Junior Member
kepper is offline
Posts: 50
PX Cash: 1,765
kepper is on a distinguished road
Rep Power: 50
Default Re: [TUT] C++/C# Sample Codes

elo boss,,how bout switch case ..ang output po is ung ask ng project na gustu nya taz lalabas ung pipiliin mo..actually a compilation project..
  Reply With Quote
Reply

Bookmarks


Facebook Comments

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Your Ad Here


All times are GMT +8. The time now is 06:33 AM.


Powered by: vBulletin
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

Disclaimer: None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site’s users. All references are copyright to their respective owners. Pinoyxtreme.com is not responsible for what its users post, or any other actions of its users. Pinoyxtreme.com is not responsible for the accuracy, compliance, copyright, legality, decency, or any other aspect of the content of other linked sites. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms.