Posts

Showing posts from April, 2021

C++ conditional statement Hacker rank solution.

 Task: Given a positive integer "n" do the followings. a) if 0<= n <= 9 . Then print the lowercase english word corresponding to the number. Ex: One for 1, Two for 2... b).  If n>9 . Then print "Greater than 9"; program for this:- int main(){    int n;   cin>>n;   string num[10]={"Greater than 9", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; if(n>9){     cout<< num[0]; } else{ cout<<num[n]; } return 0; }

Solution of c programming. PLAYING WITH CHARACTER with hacker rank

 /* Task You have to print the character,   , in the first line. Then print     in next line. In the last line print the sentence,   Sample Input 0 C Language Welcome To C!! Sample Output 0 C Language   Welcome To C!! */ #include   < stdio.h > #include   < string.h > #include   < math.h > #include   < stdlib.h > int   main ()   { char   ch ; char   s [ 100 ]; char   sen [ 100 ];      scanf ( "%c" ,   & ch );      scanf ( "%s" ,   & s );      scanf ( "\n" );      scanf ( "%[^\n]%*s" ,   & sen );                printf ( "%c \n" , ch );      printf ( "%s \n" ,   s );      printf ( "%s " , sen );      /* Enter your code here....

Basic Data Type Program solution by Hacker Rank.

  #include   < iostream > #include   < cstdio > #include   < bits/stdc++.h > using   namespace   std ; int   main ()   {      // Complete the code.      int   a ;   long   b ;   char   c ;   float   d ;   double   e ;      cin >> a >> b >> c >> d >> e ;      cout << a << "\n" << b << "\n" << c << "\n" ;      cout << fixed << setprecision ( 3 )<< d << "\n" ;      cout << fixed << setprecision ( 9 )<< e << "\n" ;      return   0 ; }

Program to add elemnts of an array

Problem is Here-----   #include   < bits/stdc++.h > using   namespace   std ; vector < string >   split_string ( string ); /*  * Complete the simpleArraySum function below.  */ int   simpleArraySum ( vector < int >   ar )   {      /*      * Write your code here.      */ } int   main () {      ofstream   fout ( getenv ( "OUTPUT_PATH" ));      int   ar_count ;      cin   >>   ar_count ;      cin . ignore ( numeric_limits < streamsize >:: max (),   '\n' );      string   ar_temp_temp ;      getline ( cin ,   ar_temp_temp );      vector < string >   ar_temp   =   split_string ( ar_temp_temp );  ...

Addition of two Integers.

  #include   < cmath > #include   < cstdio > #include   < vector > #include   < iostream > #include   < algorithm > using   namespace   std ; int   solveMeFirst ( int   a ,   int   b )   {        return   a + b ; // Hint: Type return a+b; below: } int   main ()   {    int   num1 ,   num2 ;    int   sum ;    cin >> num1 >> num2 ;    sum   =   solveMeFirst ( num1 , num2 );    cout << sum ;    return   0 ; }