SlideShare une entreprise Scribd logo
1  sur  10
Programação Estruturada II
CÓDIGO FONTE DA AULA 05
PONTEIROS – 2015.1
Prof. Thomás da Costa
thomasdacosta@gmail.com
TEMA: Aula de LAB 04 – PONTEIROS – 2015.1
Nos exercíciosdessaaula, iremosseguiros seguintespassos:
1) Copiar os exercíciospara o Dev-C++ e analisar sua execução.
2) Após a cópia, escrevernesta folhao que foi identificadonaexecuçãodo programa.
3) Por favormanter a atençãona aula, evitaracessosà internete outrasdistrações,para melhorentendimento
dos programas
Boa Codificação
Prof. Thomás da Costa
CENTRO UNIVERSITÁRIO ANHANGUERA DE SÃO PAULO
Unidade Marte: Av. Braz Leme, 3.029 – Santana – São Paulo (SP) – 02022-011 – (11) 2972-9000
DISCIPLINA: Programação Estruturada II
PROFESSOR: Thomás da Costa
ALUNO: RA:
TURMA: PERÍODO: DATA:
CURSO:
AVALIAÇÃO: ASS. PROFESSOR:
1) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr;
cout << ptr << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
2) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr;
int valor;
valor = 1500;
ptr = &valor;
cout << ptr << endl;
cout << *ptr << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
3) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr;
int valor;
int total;
valor = 1600;
ptr = &valor;
total = *ptr;
cout << *ptr << endl;
cout << total << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
4) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
// PROGRAMA COM ERRO NAO COMPILA !!!!
int *ptr_inteiro;
double valor;
valor = 345.76;
ptr_inteiro = &valor;
cout << *ptr_inteiro << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
5) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr_inteiro;
double valor;
valor = 345.76;
ptr_inteiro = (int *)&valor;
cout << *ptr_inteiro << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
6) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr_inteiro;
double valor_1;
double valor_2;
valor_1 = 345.76;
ptr_inteiro = (int *)&valor_1;
valor_2 = *ptr_inteiro;
cout << valor_1 << endl;
cout << *ptr_inteiro << endl;
cout << valor_2 << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
7) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr;
int x;
ptr = &x;
*ptr = 999;
cout << &x << endl;
cout << ptr << endl;
cout << *ptr << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
8) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr;
int x;
ptr = &x;
*ptr = 999;
cout << "Valor Original:" << ptr << endl;
ptr++;
cout << "Incremento:" << ptr << endl;
ptr--;
cout << "Decremento:" << ptr << endl;
(*ptr)++;
cout << "Inc. valor:" << *ptr << endl;
(*ptr)--;
cout << "Dec. valor:" << *ptr << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
9) explique a funcionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
double *ptr;
double x;
ptr = &x;
*ptr = 999.98;
cout << "Valor Original:" << ptr << endl;
ptr++;
cout << "Incremento:" << ptr << endl;
ptr--;
cout << "Decremento:" << ptr << endl;
(*ptr)++;
cout << "Inc. valor:" << *ptr << endl;
(*ptr)--;
cout << "Dec. valor:" << *ptr << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
10) explique afuncionalidade doprograma abaixo:
#include <iostream>
using namespace std;
int main()
{
int *ptr_1;
int *ptr_2;
int x, y;
ptr_1 = &x;
ptr_2 = &y;
cout << ptr_1 << endl;
cout << ptr_2 << endl;
cout << (ptr_1 > ptr_2) << endl;
cout << (ptr_1 < ptr_2) << endl;
ptr_1 = &x;
ptr_2 = &x;
cout << (ptr_1 == ptr_2) << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
11) explique afuncionalidade doprograma abaixo:
#include <iostream>
#include <strings.h>
using namespace std;
int main()
{
char valores[100];
char *ptr;
strcpy(valores, "Isto é um teste");
ptr = valores;
cout << valores << endl;
cout << ptr << endl;
ptr = (char *)"Isto é um outro teste";
cout << ptr << endl;
cout << valores[3] << endl;
cout << *(ptr+3) << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
12) explique afuncionalidade doprograma abaixo:
#include <iostream>
#include <strings.h>
#include <stdlib.h>
using namespace std;
int main()
{
int *ptr_1, *ptr_2;
int valor_1, valor_2;
char valor_convertido[100];
ptr_1 = &valor_1;
ptr_2 = &valor_2;
valor_1 = 316;
valor_2 = 206;
*ptr_1 = *ptr_1 << 2;
cout << *ptr_1 << endl;
*ptr_1 = *ptr_1 >> 2;
cout << *ptr_1 << endl;
itoa(*ptr_1, valor_convertido, 2);
cout << "Valor binário:" << valor_convertido << endl;
itoa(*ptr_2, valor_convertido, 2);
cout << "Valor binário:" << valor_convertido << endl;
itoa(*ptr_2 & *ptr_1, valor_convertido, 2);
cout << "Operador AND:" << valor_convertido << endl;
itoa(*ptr_2 | *ptr_1, valor_convertido, 2);
cout << "Operador OR:" << valor_convertido << endl;
itoa(*ptr_2 ^ *ptr_1, valor_convertido, 2);
cout << "Operador XOR:" << valor_convertido << endl;
itoa(~*ptr_2, valor_convertido, 2);
cout << "Operador NEG:" << valor_convertido << endl;
}
Resposta:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________

Contenu connexe

Similaire à Programação Estruturada 2 - Aula 05 - Código Fonte

Computing_Year 10_Track 1_Student Paper.pdf
Computing_Year 10_Track 1_Student Paper.pdfComputing_Year 10_Track 1_Student Paper.pdf
Computing_Year 10_Track 1_Student Paper.pdfraheeema suleman
 
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...Stu Jardine
 
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South Wa
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South WaLA020088, Assignment 2, UEENEEE137A Ed1 1 © New South Wa
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South WaTatianaMajor22
 
Program 1 assignment kit
Program 1 assignment kitProgram 1 assignment kit
Program 1 assignment kitsebas2704
 
Program 1 assignment kit
Program 1 assignment kitProgram 1 assignment kit
Program 1 assignment kitsebas2704
 
Formato notas
 Formato notas Formato notas
Formato notasutolima
 
Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)Taise Leão
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++smumbahelp
 
Paras_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInfParas_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInfParas Saini
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxravi2692kumar
 
2s complement binary
2s complement binary2s complement binary
2s complement binarySampath Reddy
 
Majeed khan resume with passport+photo+cnic
Majeed khan resume with passport+photo+cnicMajeed khan resume with passport+photo+cnic
Majeed khan resume with passport+photo+cnicMajeed Raju
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdfPradipShinde53
 
Pm0015 quantitative methods in project management
Pm0015 quantitative methods in project managementPm0015 quantitative methods in project management
Pm0015 quantitative methods in project managementsmumbahelp
 

Similaire à Programação Estruturada 2 - Aula 05 - Código Fonte (20)

Computing_Year 10_Track 1_Student Paper.pdf
Computing_Year 10_Track 1_Student Paper.pdfComputing_Year 10_Track 1_Student Paper.pdf
Computing_Year 10_Track 1_Student Paper.pdf
 
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...
P3 Productivity Consulting & Training - 10’ work-area rule & lost time (sampl...
 
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South Wa
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South WaLA020088, Assignment 2, UEENEEE137A Ed1 1 © New South Wa
LA020088, Assignment 2, UEENEEE137A Ed1 1 © New South Wa
 
Program 1 assignment kit
Program 1 assignment kitProgram 1 assignment kit
Program 1 assignment kit
 
Program 1 assignment kit
Program 1 assignment kitProgram 1 assignment kit
Program 1 assignment kit
 
Formato notas
 Formato notas Formato notas
Formato notas
 
Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)
 
Mca2030 object oriented programming – c++
Mca2030  object oriented programming – c++Mca2030  object oriented programming – c++
Mca2030 object oriented programming – c++
 
CV ENGLISH
CV ENGLISHCV ENGLISH
CV ENGLISH
 
Paras_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInfParas_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInf
 
Lecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptxLecture 3.2.4 C pointer to Structure.pptx
Lecture 3.2.4 C pointer to Structure.pptx
 
2s complement binary
2s complement binary2s complement binary
2s complement binary
 
CSE0105 Class 0.pdf
CSE0105 Class 0.pdfCSE0105 Class 0.pdf
CSE0105 Class 0.pdf
 
SUBHASREE MUKHERJEE
SUBHASREE MUKHERJEESUBHASREE MUKHERJEE
SUBHASREE MUKHERJEE
 
Majeed khan resume with passport+photo+cnic
Majeed khan resume with passport+photo+cnicMajeed khan resume with passport+photo+cnic
Majeed khan resume with passport+photo+cnic
 
charishma mechanical
charishma mechanicalcharishma mechanical
charishma mechanical
 
Sql server 2008 admin
Sql server 2008 adminSql server 2008 admin
Sql server 2008 admin
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
 
Pm0015 quantitative methods in project management
Pm0015 quantitative methods in project managementPm0015 quantitative methods in project management
Pm0015 quantitative methods in project management
 
Telecom Churn Analysis
Telecom Churn AnalysisTelecom Churn Analysis
Telecom Churn Analysis
 

Plus de thomasdacosta

Azure Functions e Java: Do Desenvolvimento a Produção
Azure Functions e Java: Do Desenvolvimento a ProduçãoAzure Functions e Java: Do Desenvolvimento a Produção
Azure Functions e Java: Do Desenvolvimento a Produçãothomasdacosta
 
Programação de Sistemas Distribuídos - Aula 03
Programação de Sistemas Distribuídos - Aula 03Programação de Sistemas Distribuídos - Aula 03
Programação de Sistemas Distribuídos - Aula 03thomasdacosta
 
Organização de Computadores - Aula 03
Organização de Computadores - Aula 03Organização de Computadores - Aula 03
Organização de Computadores - Aula 03thomasdacosta
 
Organização de Computadores - Aula 01
Organização de Computadores - Aula 01Organização de Computadores - Aula 01
Organização de Computadores - Aula 01thomasdacosta
 
Redes de Computadores - Exercícios 06
Redes de Computadores - Exercícios 06Redes de Computadores - Exercícios 06
Redes de Computadores - Exercícios 06thomasdacosta
 
Redes de Computadores - Exercícios 05
Redes de Computadores - Exercícios 05Redes de Computadores - Exercícios 05
Redes de Computadores - Exercícios 05thomasdacosta
 
Programação Concorrente - Aula 07
Programação Concorrente - Aula 07Programação Concorrente - Aula 07
Programação Concorrente - Aula 07thomasdacosta
 
Programação Concorrente - Aula 06
Programação Concorrente - Aula 06Programação Concorrente - Aula 06
Programação Concorrente - Aula 06thomasdacosta
 
Redes de Computadores - Exercícios 04
Redes de Computadores - Exercícios 04Redes de Computadores - Exercícios 04
Redes de Computadores - Exercícios 04thomasdacosta
 
Redes de Computadores - Aula 05
Redes de Computadores - Aula 05Redes de Computadores - Aula 05
Redes de Computadores - Aula 05thomasdacosta
 
Programação Concorrente - Aula 05
Programação Concorrente - Aula 05Programação Concorrente - Aula 05
Programação Concorrente - Aula 05thomasdacosta
 
Linguagem de Programação Java
Linguagem de Programação JavaLinguagem de Programação Java
Linguagem de Programação Javathomasdacosta
 
Redes de Computadores - Aula 04
Redes de Computadores - Aula 04Redes de Computadores - Aula 04
Redes de Computadores - Aula 04thomasdacosta
 
Algoritmos e Estrutura de Dados - Aula 05
Algoritmos e Estrutura de Dados - Aula 05Algoritmos e Estrutura de Dados - Aula 05
Algoritmos e Estrutura de Dados - Aula 05thomasdacosta
 
Algoritmos e Estrutura de Dados - Aula 04
Algoritmos e Estrutura de Dados - Aula 04Algoritmos e Estrutura de Dados - Aula 04
Algoritmos e Estrutura de Dados - Aula 04thomasdacosta
 
Programação Concorrente - Aula 03
Programação Concorrente - Aula 03Programação Concorrente - Aula 03
Programação Concorrente - Aula 03thomasdacosta
 
Algoritmos e Estrutura de Dados - Aula 03
Algoritmos e Estrutura de Dados - Aula 03Algoritmos e Estrutura de Dados - Aula 03
Algoritmos e Estrutura de Dados - Aula 03thomasdacosta
 
Redes de Computadores - Aula 03
Redes de Computadores - Aula 03Redes de Computadores - Aula 03
Redes de Computadores - Aula 03thomasdacosta
 
Redes de Computadores - Aula 02
Redes de Computadores - Aula 02Redes de Computadores - Aula 02
Redes de Computadores - Aula 02thomasdacosta
 
Programação Concorrente - LAB 01
Programação Concorrente - LAB 01Programação Concorrente - LAB 01
Programação Concorrente - LAB 01thomasdacosta
 

Plus de thomasdacosta (20)

Azure Functions e Java: Do Desenvolvimento a Produção
Azure Functions e Java: Do Desenvolvimento a ProduçãoAzure Functions e Java: Do Desenvolvimento a Produção
Azure Functions e Java: Do Desenvolvimento a Produção
 
Programação de Sistemas Distribuídos - Aula 03
Programação de Sistemas Distribuídos - Aula 03Programação de Sistemas Distribuídos - Aula 03
Programação de Sistemas Distribuídos - Aula 03
 
Organização de Computadores - Aula 03
Organização de Computadores - Aula 03Organização de Computadores - Aula 03
Organização de Computadores - Aula 03
 
Organização de Computadores - Aula 01
Organização de Computadores - Aula 01Organização de Computadores - Aula 01
Organização de Computadores - Aula 01
 
Redes de Computadores - Exercícios 06
Redes de Computadores - Exercícios 06Redes de Computadores - Exercícios 06
Redes de Computadores - Exercícios 06
 
Redes de Computadores - Exercícios 05
Redes de Computadores - Exercícios 05Redes de Computadores - Exercícios 05
Redes de Computadores - Exercícios 05
 
Programação Concorrente - Aula 07
Programação Concorrente - Aula 07Programação Concorrente - Aula 07
Programação Concorrente - Aula 07
 
Programação Concorrente - Aula 06
Programação Concorrente - Aula 06Programação Concorrente - Aula 06
Programação Concorrente - Aula 06
 
Redes de Computadores - Exercícios 04
Redes de Computadores - Exercícios 04Redes de Computadores - Exercícios 04
Redes de Computadores - Exercícios 04
 
Redes de Computadores - Aula 05
Redes de Computadores - Aula 05Redes de Computadores - Aula 05
Redes de Computadores - Aula 05
 
Programação Concorrente - Aula 05
Programação Concorrente - Aula 05Programação Concorrente - Aula 05
Programação Concorrente - Aula 05
 
Linguagem de Programação Java
Linguagem de Programação JavaLinguagem de Programação Java
Linguagem de Programação Java
 
Redes de Computadores - Aula 04
Redes de Computadores - Aula 04Redes de Computadores - Aula 04
Redes de Computadores - Aula 04
 
Algoritmos e Estrutura de Dados - Aula 05
Algoritmos e Estrutura de Dados - Aula 05Algoritmos e Estrutura de Dados - Aula 05
Algoritmos e Estrutura de Dados - Aula 05
 
Algoritmos e Estrutura de Dados - Aula 04
Algoritmos e Estrutura de Dados - Aula 04Algoritmos e Estrutura de Dados - Aula 04
Algoritmos e Estrutura de Dados - Aula 04
 
Programação Concorrente - Aula 03
Programação Concorrente - Aula 03Programação Concorrente - Aula 03
Programação Concorrente - Aula 03
 
Algoritmos e Estrutura de Dados - Aula 03
Algoritmos e Estrutura de Dados - Aula 03Algoritmos e Estrutura de Dados - Aula 03
Algoritmos e Estrutura de Dados - Aula 03
 
Redes de Computadores - Aula 03
Redes de Computadores - Aula 03Redes de Computadores - Aula 03
Redes de Computadores - Aula 03
 
Redes de Computadores - Aula 02
Redes de Computadores - Aula 02Redes de Computadores - Aula 02
Redes de Computadores - Aula 02
 
Programação Concorrente - LAB 01
Programação Concorrente - LAB 01Programação Concorrente - LAB 01
Programação Concorrente - LAB 01
 

Dernier

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Dernier (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Programação Estruturada 2 - Aula 05 - Código Fonte

  • 1. Programação Estruturada II CÓDIGO FONTE DA AULA 05 PONTEIROS – 2015.1 Prof. Thomás da Costa thomasdacosta@gmail.com
  • 2. TEMA: Aula de LAB 04 – PONTEIROS – 2015.1 Nos exercíciosdessaaula, iremosseguiros seguintespassos: 1) Copiar os exercíciospara o Dev-C++ e analisar sua execução. 2) Após a cópia, escrevernesta folhao que foi identificadonaexecuçãodo programa. 3) Por favormanter a atençãona aula, evitaracessosà internete outrasdistrações,para melhorentendimento dos programas Boa Codificação Prof. Thomás da Costa CENTRO UNIVERSITÁRIO ANHANGUERA DE SÃO PAULO Unidade Marte: Av. Braz Leme, 3.029 – Santana – São Paulo (SP) – 02022-011 – (11) 2972-9000 DISCIPLINA: Programação Estruturada II PROFESSOR: Thomás da Costa ALUNO: RA: TURMA: PERÍODO: DATA: CURSO: AVALIAÇÃO: ASS. PROFESSOR:
  • 3. 1) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr; cout << ptr << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ 2) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr; int valor; valor = 1500; ptr = &valor; cout << ptr << endl; cout << *ptr << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 4. 3) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr; int valor; int total; valor = 1600; ptr = &valor; total = *ptr; cout << *ptr << endl; cout << total << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ 4) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { // PROGRAMA COM ERRO NAO COMPILA !!!! int *ptr_inteiro; double valor; valor = 345.76; ptr_inteiro = &valor; cout << *ptr_inteiro << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 5. 5) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr_inteiro; double valor; valor = 345.76; ptr_inteiro = (int *)&valor; cout << *ptr_inteiro << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ 6) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr_inteiro; double valor_1; double valor_2; valor_1 = 345.76; ptr_inteiro = (int *)&valor_1; valor_2 = *ptr_inteiro; cout << valor_1 << endl; cout << *ptr_inteiro << endl; cout << valor_2 << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 6. 7) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr; int x; ptr = &x; *ptr = 999; cout << &x << endl; cout << ptr << endl; cout << *ptr << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ 8) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr; int x; ptr = &x; *ptr = 999; cout << "Valor Original:" << ptr << endl; ptr++; cout << "Incremento:" << ptr << endl; ptr--; cout << "Decremento:" << ptr << endl; (*ptr)++; cout << "Inc. valor:" << *ptr << endl; (*ptr)--; cout << "Dec. valor:" << *ptr << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 7. 9) explique a funcionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { double *ptr; double x; ptr = &x; *ptr = 999.98; cout << "Valor Original:" << ptr << endl; ptr++; cout << "Incremento:" << ptr << endl; ptr--; cout << "Decremento:" << ptr << endl; (*ptr)++; cout << "Inc. valor:" << *ptr << endl; (*ptr)--; cout << "Dec. valor:" << *ptr << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 8. 10) explique afuncionalidade doprograma abaixo: #include <iostream> using namespace std; int main() { int *ptr_1; int *ptr_2; int x, y; ptr_1 = &x; ptr_2 = &y; cout << ptr_1 << endl; cout << ptr_2 << endl; cout << (ptr_1 > ptr_2) << endl; cout << (ptr_1 < ptr_2) << endl; ptr_1 = &x; ptr_2 = &x; cout << (ptr_1 == ptr_2) << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 9. 11) explique afuncionalidade doprograma abaixo: #include <iostream> #include <strings.h> using namespace std; int main() { char valores[100]; char *ptr; strcpy(valores, "Isto é um teste"); ptr = valores; cout << valores << endl; cout << ptr << endl; ptr = (char *)"Isto é um outro teste"; cout << ptr << endl; cout << valores[3] << endl; cout << *(ptr+3) << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________
  • 10. 12) explique afuncionalidade doprograma abaixo: #include <iostream> #include <strings.h> #include <stdlib.h> using namespace std; int main() { int *ptr_1, *ptr_2; int valor_1, valor_2; char valor_convertido[100]; ptr_1 = &valor_1; ptr_2 = &valor_2; valor_1 = 316; valor_2 = 206; *ptr_1 = *ptr_1 << 2; cout << *ptr_1 << endl; *ptr_1 = *ptr_1 >> 2; cout << *ptr_1 << endl; itoa(*ptr_1, valor_convertido, 2); cout << "Valor binário:" << valor_convertido << endl; itoa(*ptr_2, valor_convertido, 2); cout << "Valor binário:" << valor_convertido << endl; itoa(*ptr_2 & *ptr_1, valor_convertido, 2); cout << "Operador AND:" << valor_convertido << endl; itoa(*ptr_2 | *ptr_1, valor_convertido, 2); cout << "Operador OR:" << valor_convertido << endl; itoa(*ptr_2 ^ *ptr_1, valor_convertido, 2); cout << "Operador XOR:" << valor_convertido << endl; itoa(~*ptr_2, valor_convertido, 2); cout << "Operador NEG:" << valor_convertido << endl; } Resposta: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________