Mostrando entradas con la etiqueta stdlib.h. Mostrar todas las entradas
Mostrando entradas con la etiqueta stdlib.h. Mostrar todas las entradas

jueves, 5 de marzo de 2015

Valor Absoluto de un número en c++ – Accident – Money – Motor – Accident – Record

Valor absoluto c++ tutorial

Elvalor absoluto de un número real es su valor numérico sin tener en cuenta su signo, sea este positivo o negativo,el valor absoluto se refiere a la distancia que existe desde un número al origen.
Ejemplo el valor absoluto de 3 es 3 a su vez el valor absoluto de -3 es 3.

--------------------------------------------------
-3 2 1 0 1 2 3

Sí observamos la recta real, la distancia que existe desde 0 a -3 es 3, similarmente de 0 a 3.

Para encontrar elvalor absoluto de un número en c++, haremos uso de la funciónabs de la libreríastdlib.h

Vamos a hacer un programa en c++ que nos pida que ingresemos por teclado un número entero cualquiera y nos imprima su valor absoluto.

#include iostream
#include stdlib.h
//#include
using namespace std;

int main(){
int a;
int absoluto;
cout "Ingrese un número" endl;
cin a;
absoluto = abs(a);
cout "El absoluto de " a " es " absoluto;
return 0;
}

Declaramos dos variables de tipo int y pedimos al usuario queingrese un número entero cualquiera. Posterior a estoguardamos el número en la variablea y obtenemos su valor absoluto con la funciónabs, el resultado lo guardamos en la variableabsoluto. Finalmente imprimimos el resultado.

Salida:

Ingrese un número
-5
El absoluto de -5 es 5

Vamos a hacer algo un poco mas interesante...

Realicemos un programa en c++ el cual nos generealeatoriamente 10 número enteros (positivos y negativos) y nos imprima su valor absoluto.

#include iostream
#include stdlib.h

using namespace std;

int main(){
int a;
for(int i = 0; i 10; i++){
a = rand()%10 - 6;
cout "El absoluto de " a " es " abs(a) endl;
}
return 0;
}

Creamos una variablea de tipoint,posterior a esto hacemos un ciclo for que se repetirá 10 veces, en cada ciclo la variablea tomará un valor aleatorio que será el resultado derand()%10 - 6,donderand()%10 nosgenera un número aleatorio entre 0 y 9 (10 - 1) y a este número aleatorio lerestaremos 6 (con el objetivo de obtener números negativos en algunas ocasiones). Por último, imprimimos el número aleatorio guardado en la variablea y su valor absoluto obtenido por lafunción abs.

Salida:

El absoluto de -5 es 5
El absoluto de 1 es 1
El absoluto de -2 es 2
El absoluto de -6 es 6
El absoluto de 3 es 3
El absoluto de -2 es 2
El absoluto de 2 es 2
El absoluto de 2 es 2
El absoluto de -4 es 4
El absoluto de -2 es 2


También te podría interesar:

  1. Operaciones básicas para vectores de objetos en c++ (Acceso, Inserción, Tamaño y eliminación)
  2. Elemento menor de un vector en C++ (min_element)
  3. Elemento mayor de un vector en C++ (max_element)
  4. Algoritmo - Factorial de un número en C++
  5. Matriz de la relación predecesor inmediato en c++.


Live casino ONLINE MOTOR INSURANCE QUOTES Donating Used Cars to Charity orlando criminal attorney DONATE CARS IN MA STRUCTURED ANNUITY SETTLEMENT Make money online Australia Criminal defense lawyer CAR INSURANCE QUOTES PA Social media platforms for business Donate cars in ma motorcycle accident lawyer california Bankruptcy lawyer most profitable internet business google adsense personal injury solicitor New social media platforms HARDDRIVE DATA RECOVERY SERVICES AUTO ACCIDENT ATTORNEY attorney lawyer mesothelioma Business management software Business finance group Casino reviews Online casino personal injury firm ASBESTOS LAWYERS Casino Psychic for Free Donate Car for Tax Credit MORTGAGE ADVISER Best social media platforms for business structured settlement blog Online College Course Mobile casino houston mesothelioma attorney Car insurance quotes pa domain registration yahoo what is structured settlement maritime lawyer houston chicago hair laser removal Mesothelioma Law Firm Cheap Car Insurance in Virginia arizona auto accident attorney WordPress hosting CRIMINAL DEFENSE ATTORNEYS FLORIDA new mexico mesothelioma lawyer Christmas cards Online Christmas cards world trade center footage Personal Injury Law Firm DUI lawyer Nunavut Culture domain name yahoo holland michigan college Hire php developers Custom WordPress theme designer diagnosed with mesothelioma Hard drive Data Recovery Services Hire php programmers ashely madis buyer of structured settlement annuity cheap car insurance in virginia Dwi lawyer new york mesothelioma law firm firm law mesothelioma Criminal lawyer Donate a Car in Maryland Virtual Data Rooms Best Seo company Asbestos Lawyers Service business software mesothelioma attorneys california motorcycle lawyer los angeles NUNAVUT CULTURE Online motor insurance quotes Neuson buy structured settlements Hire php developer Php programmers for hire asbestos lung cancer Seo companies baltimore mesothelioma attorneys Computer science classes online truck accident attorney los angeles Paperport promotional code bus accident attorney los angeles Italian cooking school online criminal justice degree Mortgage Adviser Automobile Accident Attorney structured settlement cash out Php programmers Car insurance quotes Colorado Gas/Electricity Online Colleges Car Insurance Quotes MN refinance with poor credit Html email Mortgage adviser structured settlement investments Cheap Domain Registration Hosting forensics online course Donate your Car for Money buy gift card insurance medical temporary virtual data rooms Hard drive data recovery services motor replacements Donate Your Car Sacramento Car insurance quotes Utah Seo services CAR INSURANCE QUOTES UTAH HOLLAND MICHIGAN COLLEGE Motor Insurance Quotes Best social media platforms donate old cars to charity structured annuity settlement primary pulmonary hypertension la personal injury lawyer Seo company Custom Christmas cards Criminal defense attorneys Florida Photo Christmas cards CHEAP CAR INSURANCE IN VIRGINIA Health Records Personal Health Record LOW CREDIT LINE CREDIT CARDS Car Accident Lawyers mesothelioma charities Royalty Free Images Stock WordPress themes for designers Forensics Online Course georgia truck accident lawyer Psd to WordPress Social media examiner Social media management houston motorcycle accident lawyer Tech school How to Donate A Car in California Social media platforms email bulk service Proud Italian cook mesothelioma lawyer houston life insurance quotes Psd to html WordPress theme designers mesothelioma claim DONATING A CAR IN MARYLAND World trade center footage Adobe illustrator classes asbestos lawyers Social media strategies Learning adobe illustrator auto accident lawyer san francisco REGISTER FREE DOMAINS motorcycle accident lawyer san francisco Social media tools Massage school Dallas Texas Met Auto Motor Replacements student loan consolidation program Social media campaigns Donate Car to Charity California Donate Cars in MA Data Recovery Raid Sell Annuity Payment Donate Your Car for Kids Car Donate california mesothelioma attorney injury lawyers west palm beach Structures Annuity Settlement bus accident attorneys Car Insurance Quotes Colorado verizon sip Donating used cars to charity royalty free images stock Holland Michigan College Annuity Settlements Dayton Freight Lines Donate old cars to charity Donating a Car in Maryland donating used cars to charity lawsuit mesothelioma business voip solutions Online Motor Insurance Quotes selling my structured settlement criminal defense attorneys florida alabama mesothelioma lawyer Donate Cars Illinois Car Insurance Quotes Utah yahoo web hosting Criminal Defense Attorneys Florida Best Criminal Lawyers in Arizona Cheap car insurance in Virginia PAPERPORT PROMOTIONAL CODE personal injury attorney ocala fl Donate cars Illinois Life Insurance Co Lincoln Cheap Car Insurance for Ladies mesothelioma drug Donate Car To Charity CALIFORNIA Car Insurance Quotes meso lawyer online colledges World Trade Center Footage Paperport Promotional Code Online Classes Massage School Dallas Texas BEST CRIMINAL LAWYER IN ARIZONA caraccidentlawyer criminal defense federal lawyer Donate Old Cars to Charity CAR INSURANCE IN SOUTH DAKOTA Low Credit Line Credit Cards Dallas Mesothelioma Attorneys SELL ANNUITY PAYMENT best criminal lawyer in arizona mesothelioma survival rates Cheap Auto Insurance in VA WEBEX COSTS Home Phone Internet Bundle WORLD TRADE CENTER FOOTAGE PHD on Counseling Education DONATING USED CARS TO CHARITY Car Insurance Quotes PA donate car for tax credit Car Insurance in South Dakota BETTER CONFERENCING CALLS Email Bulk Service Webex Costs houston tx auto insurance LIFE INSURANCE CO LINCOLN Register Free Domains Better Conference Calls Online Stock Trading Futuristic Architecture workers compensation lawyer los angeles Insurance Companies PSYCHIC FOR FREE structured settlement need cash now Auto Accident Attorney HOW TO DONATE A CAR IN CALIFORNIA tennessee mesothelioma lawyer Criminal lawyer Miami Donate car to charity California Personal Injury Lawyers Asbestos Lung Cancer saskatchewan auto insurance Injury Lawyers PHD IN COUNSELING EDUCATION donate your car for money

viernes, 5 de julio de 2013

Abrir una direccion web con c++. – Phone – cancer



Para abrir direcciones web conc++ lo que haremos será usar la funciónsystem de la libreríastdlib.h de la siguiente manera:

system("start www.WebQueQuieresAbrir.com");

Donde"Start" abre la dirección y "www.WebQueQuieresAbrir.com" es la dirección que quieres abrir.

Un ejemplo de esto sería algo como:

system("start www.google.com");

Esto lo que hará será abrirwww.google.comen nuestro navegador predeterminado.

Veamos algo un poco más formal:

#include iostream
#include stdlib.h

using namespace std;

int main(){
cout "Presione enter para abrir www.google.com" endl;
system("pausenull");
system("start www.google.com");
cout "Presione enter para salir" endl;
system("pausenull");
return 0;
}

La consola nos dirá que presionemos la tecla enter para abrirgoogle.com, "system("pausenull");" se encargará de pausar el programa hasta que presionemos enter,"system("start www.google.com");" abrirá google.com en nuestro navegador predeterminado, y"system("pausenull");" nuevamente pausará el programa y luego de presionar la tecla enter (ó cualquiere otra) éste se cerrará.

Y si desean abrir más de una dirección web lo que deben hacer es usar la sentencia switch case, esto sería:

#include iostream
#include stdlib.h

using namespace std;

int main(){
system("cls");
cout "Presione 1 y luego enter para abrir www.google.com" endl;
cout "Presione 2 y luego enter para abrir www.youtube.com" endl;
cout "Presione 0 y luego enter para salir" endl;
int opcion;
cin opcion;
switch(opcion){
case 1:
system("start www.google.com");
main();
break;
case 2:
system("start www.youtube.com");
main();
break;
case 0:
exit(0);
break;
}
return 0;
}


Contamos con dos opciones en la consola, la primera para abrirgoogle.com y la segunda para abriryoutube.com, escribimos "main()" al final de cadacase (antes del break) para que después de ejecutar cada opción siga dentro de lafuncion main, y un "system("cls");" para limpiar la pantalla luego abrir alguna web.




Donate a car in Maryland Online Christmas cards How to donate a car in California low credit line credit cards Online casino Mobile casino DUI lawyer Criminal defense lawyer fast cash for house saskatchewan auto insurance Donate car for tax credit Live casino Social media tools AUTOMOBILE ACCIDENT ATTORNEY WEBEX COSTS Donate Car to Charity California emergency response plan ppt donate car for tax credit Holland Michigan College auto accident attorney Torrance diagnosed with mesothelioma Casino home phone internet bundle mesothelioma litigation Car Insurance Quotes PA Social media campaigns Php programmers mesothelioma law suits DONATE OLD CARS TO CHARITY DONATE CARS ILLINOIS auto accident lawyer san francisco Asbestos Lung Cancer Online motor insurance quotes Gas/Electricity Sell Annuity Payment Best social media platforms for business Make money online Australia st louis mesothelioma attorney structured annuity settlement DAYTON FREIGHT LINES Social media platforms for business mesothelioma Attorney Dwi lawyer DONATE CARS IN MA Casino reviews Social media strategies MESOTHELIOMA LAW FIRM anti spam exchange server Social media management mesothelioma settlements motorcycle accident attorney sacramento benchmark lending MORTGAGE ADVISER asbestos exposure lawyers quotes car structured settlement blog DONATING USED CARS TO CHARITY Seo company Psd to WordPress PhD in counseling education Seo services onlineclasses event management security Hire php developers cell cycle regulation ppt Low Credit Line Credit Cards Motor replacements Photo Christmas cards Donating a car in Maryland Cheap car insurance in Virginia Auto Mobile Shipping Quote MASSAGE SCHOOL DALLAS TEXAS maritime lawyer houston Donate Your Car Sacramento bus accident attorneys Donate your car for money Hire php programmers Car Insurance Quotes MN Hard drive Data Recovery Services Donate car to charity California cheap auto insurance in va WordPress hosting tennessee mesothelioma lawyer Criminal lawyer Low credit line credit cards car insurance companies Service business software Donate old cars to charity lawsuit mesothelioma asbestos lawyers Proud Italian cook Car Insurance Quotes Colorado mesothelioma trial attorney CAR INSURANCE IN SOUTH DAKOTA mesotheloma Php programmers for hire Royalty free images stock Hire php developer buyer of structured settlement annuity peritoneal mesothelioma Dayton freight lines Bankruptcy lawyer mesothelioma lawyer virginia Computer science classes online Better Conference Calls Learning adobe illustrator motorcycle accident lawyer san francisco World Trade Center Footage Seo companies Donate a Car in Maryland Car insurance quotes Colorado refinance with bad credit New social media platforms DONATE A CAR IN MARYLAND Business finance group Personal Injury Lawyers HOLLAND MICHIGAN COLLEGE Dallas mesothelioma attorneys Custom WordPress theme designer WordPress themes for designers Met Auto ONLINE COLLEDGES Best Seo company Tech school Business management software REGISTER FREE DOMAINS WORLD TRADE CENTER FOOTAGE Best social media platforms los angeles auto accident attorneys accident attorney san bernardino BEST CRIMINAL LAWYER IN ARIZONA Car Insurance Companies Dedicated Hosting Dedicated Server Hosting annuity payment CAR INSURANCE QUOTES MN Custom Christmas cards arizona auto accident attorney broward county dui lawyer Donate Cars Illinois motor replacements florida car insurance company Italian cooking school Automobile Accident Attorney Social media examiner Social media platforms Html email Cheap Car Insurance for Ladies Massage school Dallas Texas Christmas cards selling structured settlement hair removal washington dc Psd to html uk homeowner loans Car Donate WordPress theme designers FORENSICS ONLINE COURSE Adobe illustrator classes data recovery raid mesothelioma law firm Nunavut Culture auto accident attorney Car Insurance Quotes Utah Online College Course Mesothelioma Law Firm google adsense Donate Car for Tax Credit Donate Cars in MA How to Donate A Car in California Asbestos Lawyers donating used cars to charity Donate Your Car for Kids DONATE CAR FOR TAX CREDIT Mortgage adviser Structures Annuity Settlement verizon sip online motor insurance quotes Annuity Settlements injury lawyers west palm beach business voip solutions Business Voip Solutions what is structured settlement Dayton Freight Lines personal injury lawyer sarasota fl compare life assurance Injury Lawyers fortis health insurance temporary Motor Replacements structured settlement sell STRUCTURED ANNUITY SETTLEMENT Cheap Domain Registration Hosting structured settlemen Donating a Car in Maryland Criminal Defense Attorneys Florida anti spam appliance Best Criminal Lawyers in Arizona Life Insurance Co Lincoln Webex Costs car insurance quotes pa Online Motor Insurance Quotes Online Colleges Paperport Promotional Code donate your car for money truck accident attorney texas Donating Used Cars to Charity Online Classes Home phone internet bundle life insurance co lincoln Massage School Dallas Texas Psychic for Free Donate Old Cars to Charity HOW TO DONATE A CAR IN CALIFORNIA Dallas Mesothelioma Attorneys mortgage adviser average mesothelioma settlement Donate your Car for Money Cheap Auto Insurance in VA adverse remortgage Forensics Online Course Home Phone Internet Bundle Email Bulk Service PHD on Counseling Education Neuson Royalty Free Images Stock structured settlement brokers primary pulmonary hypertension mesothelioma charities houston tx auto insurance Car Insurance in South Dakota ANNUITY SETTLEMENT AUTO ACCIDENT ATTORNEY Criminal lawyer Miami Cheap Car Insurance in Virginia workers compensation lawyer los angeles HARDDRIVE DATA RECOVERY SERVICES Register Free Domains car accident lawyers west palm beach buy structured settlements structured settlement need cash now miami personal injury attorney los angeles motorcycle accident lawyer Futuristic Architecture Mortgage Adviser Virtual Data Rooms asbestos lung cancer Criminal defense attorneys Florida Auto Accident Attorney Car Accident Lawyers Data Recovery Raid Motor Insurance Quotes