SlideShare a Scribd company logo
1 of 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:
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________
_______________________________________________________________________________________________

More Related Content

Similar to 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
 

Similar to 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
 

More from thomasdacosta

More from 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
 

Recently uploaded

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
Safe Software
 
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
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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...
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
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)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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...
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

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