Q#1 #Include #Include #Include Using Namespace Void
Q#1 #Include #Include #Include Using Namespace Void
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string s;
cout<<"\n\nEnter a STRING ";
getline(cin,s);
s.erase(3,8);
cout<<"\n\nDELETED STRING "<<s;
getch();
}
Q#2
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string s;
int i;
int n=0;
cout<<"\n\nENTER A STRING ";
getline(cin,s);
for(i=0;s[i]!=0;i++)
{
n++;
}
cout<<"\n\nDELETED STRING "<<n;
getch();
}
Q#3
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
char str[20];
int i;
cout<<"\n\nEnter First Name in lowercase : ";
gets(str);
for(i=0;i<=strlen(str);i++)
{
if(str[i]>=97 && str[i]<=122)
{
str[i]=str[i]-32;
}
}
cout<<"\nThe name in UPPERCASE = "<<str;
getch();
}
Q#4
#include <iostream>
#include<conio.h>
using namespace std;
#define MAX_SIZE 100
int main()
{
char str[MAX_SIZE];
int alphabets, digits, others, i;
alphabets = digits = others = i = 0;
cout<<"\nEnter any string : ";
gets(str);
while(str[i]!='\0')
{
if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
{
alphabets++;
}
else if(str[i]>='0' && str[i]<='9')
{
digits++;
}
else
{
others++;
}
i++;
}
cout<<"\nAlphabets = "<<alphabets;
cout<<"\nDigits = "<< digits;
cout<<"\nSpecial characters = "<<others;
getch();
}