Monday, April 29, 2019

Length of the String

  • Problem Description

    Program which will accept string from the user and find the length of the string
  • Test Case 1

    Input (stdin)
    welcome

    Expected Output
    7
  • Test Case 2

    Input (stdin)
    input

    Expected Output
    5
Solution

#include <stdio.h>
#include <string.h>
 
int main()
{
  char a[100];
  int length;
  scanf ("%[^\n]s",a); 
  length = strlen(a); 
  printf("%d\n", length); 
  return 0;
}

No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...