Thursday, December 26, 2013

Assignment 6: Strings

Strings

1
Write a program to find the length of string. solution
2
Write a program to display string from backward. solution
3
Write a program to count number of words in string. solution
4
Write a program to concatenate one string contents to another. solution
5
Write a program to compare two strings they are exact equal or not. solution
6
Write a program to check a string is palindrome or not. solution
7
Write a program to find a substring within a string. If found display its starting position. solution
8
Write a program to reverse a string. solution
9
Write a program to convert a string in lowercase. solution
10
Write a program to convert a string in uppercase. solution
11
Write the output of the following program
#include <iostream.h>
#include <ctype.h>
void Encrypt(char T[])
{
            for (int i=0;T[i]!='\0';i+=2)
                        if (T[i]=='A' || T[i]=='E')
                                    T[i]='#';
                        else if (islower(T[i]))
                                    T[i]=toupper(T[i]);
                        else
                                    T[i]='@';
}
void main()
{
            char Text[]="SaVE EArtH";
            Encrypt(Text);
            cout<<Text<<endl;
}
12
Write the output of the following program
char *NAME = "CoMPutER";
for (int x = 0: x < strlen(NAME); x++)
            if (islower(NAME [x]))
                        NAME [x] = toupper(NAME[x]);
            else
                        if (isupper(NAME[x])
                                    if (x%2 ==0)
                                                NAME[x] = tolower(NAME[x]);
                                    else
                                                NAME[x] =NAME[x-1];
puts(NAME);

No comments:

Post a Comment