Computer Science, asked by Ananya3873, 1 year ago

Write a program in c to convert first character of a string to uppercase?

Answers

Answered by gokulraam0507
1

#include <stdio.h>

#include <conio.h>

#include <string.h>

void main(void)

 {

   int ctr = 0;

   char string[] = "this is a test";

   clrscr();

   printf("This is the string: \"%s\"\n", string);

   printf("Press any key to continue."); while (!kbhit());

   for(ctr = 0; ctr < strlen(string); ctr++)

     {

           if (ctr == 0)

             string[ctr] = toupper(string[ctr]);

           if (string[ctr] == ' ')

             string[ctr + 1] = toupper(string[ctr + 1]);

     }

   printf("\n\nThis is the new string: \"%s\".", string);

   getch();

 }

Similar questions