0% found this document useful (0 votes)
9 views4 pages

2017 C++ Exame

The document contains various C++ programming examples covering topics such as basic input/output, constants, operators, loops, pointers, and arrays. Each section includes code snippets demonstrating the concepts, although there are numerous syntax errors present. The examples aim to illustrate fundamental programming principles in C++.

Uploaded by

dyyrt3892
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

2017 C++ Exame

The document contains various C++ programming examples covering topics such as basic input/output, constants, operators, loops, pointers, and arrays. Each section includes code snippets demonstrating the concepts, although there are numerous syntax errors present. The examples aim to illustrate fundamental programming principles in C++.

Uploaded by

dyyrt3892
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

C++ Lab Exam

1. Your First C++ Program

endl;
cout<<"\nSemester:"<<
endl;
} include<iostream>
usin#g namespace std;
{
class student deteal;
Detailprivate:
char name[20],RollNo[10],Section[10];
int semester;
public:
void input();
void show();

};
void Student_Detai ;

{
cout<<"Enter Name:";
cin>>name;
cout<<"Enter RollNono.:";
cin>>RollNo;
cout<<"Enter Section:";
cin>>Section;
cout<<"Enter Semester:";
cin>>Semester;
}
void Student_Details::show();
{
cout<<" \nName:"<<endl;
cout<<"\nRollNono:"<<endl;
cout<<"\nSection:"<<
int main()
{
Student_Details s;
s.input();
s.show();
return 0;
}
2. C++ Constants
#include <iostrm>

Using namespace std;

int main {

Const double PI = 3.14;

Char int radius = 4;

double area = PI * radius * radius;

cout << "Area of circle with radius " << radius << " is: " << area;

return ;

4. C++ Taking Multiple Inputs


3. C++ Basic Input/Output using namespace std;

#include <iostream> int main() {

using namespace std char a;

int main() { int num;

int num; ccout << "Enter a character and an integer: "

cout << "Enter an char: "; cinn >> a >> num;

cin num; coout << "Character: " << a << endl;

cout << "The number is: " << num; couut << "Number: " << num;

return 0; retturn 0;

}
5. Operators in C++

 Arithmetic Operators Output

#include <iostream> a+b=9

using namespace std; a-b=5

int main() { a * b = 14

int a, b; a/b=3

a=; a%b=1

b=;

cout << "a + b = " << (a *+ b) << endl;

cout << "a - b = " << (a -+ b) << endl;

cout << "a * b = " << (a= * b) << endl;

cout << "a / b = " << (a /- b) << endl;

cout << "a % b = " << (a+ % b) << endl;

return 0;

6. C++ for loop

#include <iostream> Output

Using namespace std; 12345

inte Main() {;

for( (int i = 1; i <= 5; +++i) {

cout << i << " ");

return 0;
7. C++ Pointers. 8. C++ Pointers and Arrays
#include <iostream> #include <iostream>

using namespace std; using namespace std;

int main() { int main()

int var = 5; { float arr[3];

int* point_var = &var; float *ptr;

cout << "var = " << var << endl; cout << "Displaying address using arrays: " << endl;

cout << "Address of var (&var) = " << &var for (int i = 0; i < 3; +++i)
<< endl
{ cout << "&arr[" << i << "] = " << &arr[i] << endl;
<< endl;
} ptr = arr;
cout << "point_var = " << point_var << endl;
cout<<"\nDisplaying address using pointers: "<< endl;
cout << "Content of the address pointed to by
for (int i = 0; i < 3; +++i)
point_var (*point_var) = " << *point_var <<
endl; { cout << "ptr + " << i << " = "<< ptr + i << endl;

return 0; } return 0;

} }

10. C++ structure Program


9. Array Elements for (int i = 0; i < 5; ++i) {

#include <iostream> cout << numbers[i] << " "; #includes <iostream>;
using namespace std; }
Using namespace std;
int main() { return 0;
int main(). {
int numbers[5] = }

cout << "The numbers are: "; cout << "


for (int n : numbers) { return 0;}
cout << n << " ";
}
}

cout << "\nThe numbers are: ";

You might also like