Here I have listed some questions related to strings in c++, solve them to
increase your programming skills.
Problem #1:
// Problem related to strings
#include<iostream.h>
void main(void)
{
char ch[]="Programming Skills";
int i=0;
cout<<ch[++i];
cout<<ch[i++];
cout<<i++[ch];
cout<<++i[ch];
}
Problem #2:
// Problems related to strings
#include<iostream.h>
void main(void)
{
char ch[]="Programming Skills";
char *s="Programming Skills";
cout<<sizeof(ch)<<sizeof(s);
cout<<sizeof(*ch)<<sizeof(*s);
}
Problem #3:
// Problems related to strings
#include<iostream.h>
void main(void)
{
int n[]={4,3,2,1,0};
for(int i=0;i<5;i++)
cout<<n[n[i]];
}
Problem #4:
// Problems related to strings
#include<iostream.h>
void main(void)
{
int n[]={11,10,9,8,7,6,5,4,3,2,1,0};
char ch[]="C++ Language";
for(int i=0;i<12;i++)
cout<<ch[n[i]];
}
ANSWERS:
#1: rroh
#2: 19411
#3: 01234
#4: egaugnaL ++C
Good-Bye!
Related Articles: