Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Coding Question 1 Free Section

Program to Capitalise a String

C

#include <stdio.h>
 
void upper_string(char []);
 
int main()
{
   char string[100];
 
   printf("Enter a string to convert it into upper case\n");
   gets(string);
 
   upper_string(string);
 
   printf("The string in upper case: %s\n", string);
 
   return 0;
}
 
void upper_string(char s[]) {
   int c = 0;
 
   while (s[c] != '\0') {
      if (s[c] >= 'a' && s[c] <= 'z') {
         s[c] = s[c] - 32;
      }
      c++;
   }
}

using strUPR Method

#include <stdio.h>
#include <string.h>
 
int main()
{
   char string[1000];
 
   printf("Input a string to convert to upper case\n");
   gets(string);
 
   printf("The string in upper case: %s\n", strupr(string));
 
   return  0;
}

Java

import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to PrepInsta.com");

      System.out.print("Return Value :" );
      System.out.println(Str.toUpperCase() );
   }
}

4 comments on “Coding Question 1 Free Section”