0

How to make the last name first letter. Capital in this program

#include<string.h> #include<stdio.h> #include <iostream> using namespace std; int main() { char str[25][150],t[20]; int i,n,j; cout<<" Enter the number of name "; cin>>n; cout<<"\n Enter Names : \n\n"; for(i=-1;i<n;i++) { cin.getline(str[i], 100); } for(i=0; i<n; i++) { str[i][0]=toupper(str[i][0]); } for(i=1; i<n; i++) { for(j=1; j<n; j++) { if(strcmp(str[j-1], str[j])>0) { strcpy(t, str[j-1]); strcpy(str[j-1], str[j]); strcpy(str[j], t); } } } cout<<"\n Names Sorted in Alphabetical Order : \n\n"; for(i=0; i<n; i++) { cout<<" "; cout<<str[i]<<"\n"; } r

24th Nov 2019, 5:08 PM
Thomas Benny
Thomas Benny - avatar
3 odpowiedzi
0
Your code works fine. What error you getting? its fine..
24th Nov 2019, 6:28 PM
Jayakrishna 🇮🇳
0
The initial of the names first letter is not capital
25th Nov 2019, 2:51 AM
Thomas Benny
Thomas Benny - avatar
0
Run it playground and post link if didn't get result. I tested it. Its running.. Comparing start from for i=0, if you not getting...
25th Nov 2019, 8:52 AM
Jayakrishna 🇮🇳