Object Oriented Programming Object Oriented Programming Lab 004
Object Oriented Programming Object Oriented Programming Lab 004
#include <iostream>
#include <string.h>
int main()
{
string greeting;
int i;
getline (cin, greeting);
for(i=0;i<=greeting[i]!='\0';i++)
{
if(greeting[i]>=97 && greeting[i]<=122)
{
greeting[i]=greeting[i]-32;
}
}
cout<<"\nThe String in Uppercase = "<<greeting;
return 0;
}
#include <iostream>
#include <string>
int main()
{
string word,rev;
cout<<"Enter a string: "<<endl;
getline (cin,word);
int i,j,count;
for (i=0;word[i]!='\0';i++)
{
count++;
}
cout<<"Length of string is : "<<count<<endl;
count=count-1;
for (j=0;word[count]!=0;j++)
{
rev[j]=word[count];
cout<<rev[j];
count--;
}
return 0;
}
#include <iostream>
#include <string>
int main()
{
string word,copy;
cout<<"Enter a string: "<<endl;
getline (cin,word);
int j;
cout <<"Word you entered: "<<word<<endl;
cout <<"Copied word: "<<endl;
for (j=0;word[j]!='\0';j++)
{
copy[j]=word[j];
cout<<copy[j];
}
return 0;
}
#include <iostream>
#include <string>
int main()
{
string source="",copy="",naya;
cout << "Enter a string one" << endl;
getline (cin,source);
cout << "Enter a string two" << endl;
getline (cin,copy);
naya=source+" "+copy;
cout << "New string:" <<naya<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main(){
char string1[20];
int i,j,length=0;
int flag = 0;
if (flag) {
cout << string1 << " is not a palindrome" << endl;
}
else {
cout << string1 << " is a palindrome" << endl;
}
return 0;
}
6. Write a program to read a line of text and delete occurrences of particular words.
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
int i, j = 0, k = 0;
char str[100], str1[10][20], word[20];
cout<<"\n Enter String : ";
gets(str);
/* Converting the string into Two Dimensional Array */
}
cout<<"\n New String After Deleting the Word : \n\n";
for (i=0; i<k+1; i++)
{
cout<<" ";
cout<<str1[i]<<" ";
}
return 0;
}