This Manual Covers:: Exercise 8.1
This Manual Covers:: Exercise 8.1
Exercise 8.1
i. Reads 3 characters
ii. Select and display the first character among the three by writing
functions:
Exercise 8.2
#include<iostream>
int main(void)
Int i;
charcolour [] = "blue";
i=0;
{
putchar (colour[i]);
i++;
Exercise 8.3
Write the following program. The program copy a string to another string
#include <cstring>
#include <iostream>
using namespace std;
#define COPY_SIZE 64 // maximum characters to copy
int main()
{
const char *Original = "I am the original!";
char Copy[COPY_SIZE + 1] = "I am the copy!";
strcpy(Copy, Original);
cout << "After strcpy(): " << endl;
cout << "Original = " << Original << endl;
cout << "Copy = " << Copy << endl;
return 0;
Exercise 8.4
Write the following program. The program lets you know the length of a string
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
const char *String= "I am the string!";
return 0;
Exercise 8.5
Exercise 8.6
Exercise 8.7
Exercise 8.8
Compile and run following C++ code; The program demonstrates how strings are
passed to a function.
#include <iostream>
using namespace std;
int main()
{
char str[100];
string str1;
display(str);
display(str1);
return 0;
}
void display(string s)
{
cout << "You entered string: " << s << endl;
}
Exercise 8.9
Make a call to binarysearch function defined below from the main function.Compile and
run the complete C++ code;
bottom = 0;
top = size - 1;
while (!found && bottom <= top)
{
middle = (bottom + top)/2;
if (items[middle] == element)
found = true;
else
if (items[middle] > element)
top = middle - 1;
else
bottom = middle + 1;
}
return found;
}
LAB ASSIGNMENT 4
The program should determine the largest absolute value in the array and scale
each element of the array by dividing it by this largest value.
The new array, which is called the normalized array, should have the largest value.
main() obtains the number of data points, and the x, y, and z coordinates
of each point.
normalize() normalize the array.