Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Conditional Statements in C solution

YASH PAL, 12 July 202412 July 2024

In this tutorial, we are going to solve HackerRank conditional statements in the c problem or write a solution program. In this problem, we need to read the positive integer value and then we need to check if the value is greater than print the text “Greater than 9” Else we need to print the English word that corresponds to that value in lowercase like if value 1 then print the one in lowercase.

Conditional Statements in C

Problem solution in C programming.

#include<stdio.h>
#include<string.h>
int main()
{
 int n;
 scanf("%d",&n);
  char *a[]={"zero","one","two","three","four","five","six","seven","eight","nine"};
  if(n<=9)
  {
     printf("%s",a[n]);
  }

 else
 {
     printf("Greater than 9");
 }
 return 0;
}

Explanation

In the above-given program first, we included the two header files stdio.h and string.h, after that we defined the main() function. inside the main function, we first defined the integer variable n and then using the scanf() function we read the user input value and stored it in the variable n.

after that, we defined an array named a with predefined values like zero, one, two, three, four, five, six, seven, eight, and nine. we used these values to get the corresponding English words of value from 0 to 9.

After that using the if condition we checked if the value was less than or equal to 9 then using the printf() function we printed the corresponding English word from the array. else we printed the “Greater than 9” text on the output screen.

Conditional Statements in c
c coding problems hackerrank solutions cHackerRank

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
©2025 Programming101 | WordPress Theme by SuperbThemes