Exercise Solved
Exercise Solved
int main() {
float num1 = 7.3;
float num2;
}
#include<iostream>
using namespace std;
void exchange (double* x, double* y);
int main ()
{
double x = 2.5,y=1.5;
double* xptr = &x;
double* yptr = &y;
cout<<"values before swap:"<<*xptr<<" "<<*yptr<<"\n";
exchange(xptr,yptr);
}
void exchange(double* x , double* y)
{
double temp = *x;
*x = *y;
*y = temp;
cout<<*x<<" "<<*y<<"\n";
}
#include <iostream>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
int main()
{
char s[] = {'A','E','I','O','U','\0'};
int length= 0;
while (s[length]!='\0')
{
length++;
}
cout<<length<<"\n";
for (int i = 0; i < length; i++)
{
cout<<s[i]<<" ";
}
for (int i = 0; i < strlen(s); i++)
{
s[i]=tolower(s[i]);
}
cout<<"\n";
string str = "aeiou";
for (int i = 0; i < str.size(); i++)
{
str[i]=toupper(str[i]);
}
cout<<str<<"\n";
#include<iostream>
using namespace std;
int main ()
{
unsigned int values[] = {2,4,6,8,10};
const int size = 5;
unsigned int* vptr = &values[0];
for (int i = 0; i < size; i++)
{
cout<<values[i]<<" ";
}
cout<<"\n";
for (int i = 0; i < size; i++)
{
cout<<*(values+i)<<" ";
}
cout<<"\n";
for (int i = 0; i < size; i++)
{
cout<<*(vptr+i)<<" ";
}
cout<<"\n";
}
#include<iostream>
using namespace std;
int main()
{
long value1 = 5;
long value2;
long* ptr = &value1;
cout<<*ptr<<"\n";
value2 = *ptr;
cout<<value2<<"\n";
cout<<&value1<<"\n";
cout<<ptr<<"\n";
}#include<iostream>
using namespace std;
void BigIn(long int bigInt[]);
int smalli(long int smallInt[]);
int main ()
{
long bigInt [] = {1,2,3,4,5};
long smallInt []= {1,1,1,1,1};
BigIn(bigInt);
cout<<"\n"<<smalli(smallInt);
}
void BigIn(long bigInt[])
{
for (int i = 0; i < 5; i++)
{
cout<<bigInt[i]<<" ";
}
}
int smalli(long smallInt[])
{
int sum = 1;
for (int i = 0; i < 5; i++)
{
sum+=smallInt[i]+1;
}
return sum;
}
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
string name ;
cout<<"Enter your name:";
getline(cin,name);
string* ptr = &name;
cout<<ptr<<"\n";
int num = 355;
double nnum = 23.332;
cout<<uppercase<<hex<<num<<"\n";
cout<<uppercase<<scientific<<nnum<<"\n";
int* nptr = #
cout<<nptr<<"\n";
cout<<oct<<*nptr<<"\n";