Here is a C++ program to print nth character of any given string
SOURCE CODE OUTPUT
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[100];
int n;
cout<<"Enter string : ";
cin>>str;
cout<<"Enter value of n : ";
cin>>n;
cout<<"Character at nth place : "<<str[n-1];
return 0;
}
#include<string.h>
using namespace std;
int main()
{
char str[100];
int n;
cout<<"Enter string : ";
cin>>str;
cout<<"Enter value of n : ";
cin>>n;
cout<<"Character at nth place : "<<str[n-1];
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment