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.pdf
raheeema suleman
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
cadmiell
 
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
TatianaMajor22
 
Formato notas
 Formato notas Formato notas
Formato notas
utolima
 
Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)Relatório semanal (aluno) (5)
Relatório semanal (aluno) (5)
Taise Leão
 
The Outline of a ResponseThesis Statement (Write the sentence i.docx
The Outline of a ResponseThesis Statement (Write the sentence i.docxThe Outline of a ResponseThesis Statement (Write the sentence i.docx
The Outline of a ResponseThesis Statement (Write the sentence i.docx
oreo10
 
Paras_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInfParas_Saini_ver5.8.4_GeekInf
Paras_Saini_ver5.8.4_GeekInf
Paras 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.pptx
ravi2692kumar
 

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
 
My cool new Slideshow!
My cool new Slideshow!My cool new Slideshow!
My cool new Slideshow!
 
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
 
The Outline of a ResponseThesis Statement (Write the sentence i.docx
The Outline of a ResponseThesis Statement (Write the sentence i.docxThe Outline of a ResponseThesis Statement (Write the sentence i.docx
The Outline of a ResponseThesis Statement (Write the sentence i.docx
 
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
 
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
 

Plus de thomasdacosta

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

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
Victor Rentea
 

Dernier (20)

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
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 

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: _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________ _______________________________________________________________________________________________