Programming Interview Questions

Sub Category
Questions
Answers
Last Updated
57
247
Jun 27th, 2015
22
37
Nov 25th, 2014
26
39
Feb 20th, 2015
27
28
Feb 27th, 2015
66
234
Jul 24th, 2015
100
490
Jul 19th, 2015
25
54
Jul 24th, 2015
63
76
Jul 24th, 2014
21
26
Oct 3rd, 2012
46
124
Jun 1st, 2015

Showing Questions 1 - 20 of 38 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page:
  •  

    Generate no.between 32 to 99

    Consider the following number
    45*45=2025 and
    20+25=45.
    Write a program to generate no.between 32 to 99 that satisfy the above problem.

    Sambuddha Chaudhuri

    • Jul 16th, 2015

    Code
    1. public class sumbtw32and45{
    2.     public static void main(String args[]){
    3.         //Scanner sc = new Scanner(System.in);
    4.         //System.out.println("Enter the number between 32 and 99");
    5.         //int i = sc.nextInt();
    6.         //if(i >=32 && i <= 99)
    7.         int count = 0;
    8.             for(int i =32;i<=99;)
    9.             {
    10.             int j =i * i;
    11.             int temp = j %100;
    12.             int n = j /100;
    13.             int l = temp + n;
    14.             if(i == l){
    15.                System.out.println(i);
    16.                count = count +i;
    17.                i++;
    18.             }
    19.             else
    20.                i++;
    21.            }
    22.            System.out.println("the Sum of these Type of numbers is"+count);
    23.            }
    24. }

    mahamadalig

    • Apr 17th, 2012

    Code
    1. #include<stdio.h>
    2. #include<conio.h>
    3. main()
    4. {
    5.         int i,a,r,s,w;
    6.         printf("                ------ANSWER IS:---------
    7. ");
    8.         for(i=32;i<=99;i++)
    9.         {
    10.                 s=0;
    11.                 w=i;
    12.                 a=i*i;
    13.                 while(a>0)
    14.                 {
    15.                         r=a%100;
    16.                         s=s+r;
    17.                         a=a/100;
    18.                 }
    19.                 if(w==s)
    20.                 {
    21.                         printf("                           %d
    22. ",w);
    23.                 }      
    24.         }
    25.         return 0;
    26. }

  •  

    Print Sum of Digits

    Write a function to print sum of the digits in a given integer n without converting it to String. For example : if n = 1234 the function should return 1+2+3+4 = 10 if n = 15 the function should return 1+5 =6 if n = 5 the function should return 5.

    Sambuddha Chaudhuri

    • Jul 16th, 2015

    "java import java.util.Scanner; public class fourdigit{ public static void main(String args[]){ int k = 0,j = 1,l = 1; Scanner sc = new Sc...

    jenisha

    • Jul 1st, 2012

    "c #include main() { int n, sum = 0, remainder; printf("Enter an integer "); scanf("%d",&n); while(n != 0) { remainder = n % 10; sum = sum + remai...

  •  

    Solve this Programming Task in language of preference

    TASK 1: Programming Task in language of preference

    Imagine a customized computer keyboard with following layout :
    ERTYU1
    DFGHJ2
    CVBNM4

    The keyboard only has above set of keys in the panel , For a given set on input word you need to output the path taken to press them , for example :
    Consider the input word is : RFGM
    the output...

    vinod378

    • May 31st, 2015

    Code
    1. #include<stdio.h>
    2. main()
    3. {
    4.         char disc[3][6]={"ERTYU1","DFGHJ2","CVBNM4"};
    5.         char input[10];
    6.         scanf("%s",input);
    7.         int i,j,k,l,pos[4],p;
    8.         printf("PRESS %c
    9. ",input[0]);
    10.         for(p=0;input[p]!=;p++);
    11.         for(i=0;i<(p-1);i++)
    12.         {
    13.                 for (l=0;l<2;l++)
    14.                 {
    15.                         for(j=0;j<3;j++)
    16.                         {
    17.                                 for(k=0;k<6;k++)
    18.                                 {
    19.                                         if(input[i+l]==disc[j][k])
    20.                                         {
    21.                                                 if (l==0)
    22.                                                 {
    23.                                                 pos[l]=j;
    24.                                                 pos[l+1]=k;
    25.                                                 }
    26.                                                 else
    27.                                                 {
    28.                                                         pos[l+1]=j;
    29.                                                         pos[l+2]=k;
    30.                                                 }
    31.                                                 break;
    32.                                         }
    33.                                 }
    34.                         }
    35.                 }
    36.                 /*for (k=0;k<4;k++)
    37.                         printf("%d ",pos[k]);
    38.                         printf(" ");*/
    39.                         if(pos[0]>pos[2])
    40.                         {
    41.                                 for(j=0;j<(pos[0]-pos[2]);j++)
    42.                                         printf("GO UP
    43. ");
    44.                         }
    45.                         else if(pos[0]<pos[2])
    46.                         {
    47.                                 for(j=0;j<(pos[2]-pos[0]);j++)
    48.                                         printf("GO DOWN
    49. ");
    50.                         }
    51.                         if(pos[1]>pos[3])
    52.                         {
    53.                                 for(j=0;j<(pos[1]-pos[3]);j++)
    54.                                         printf("GO LEFT
    55. ");
    56.                         }
    57.                         if(pos[1]<pos[3])
    58.                         {
    59.                                 for(j=0;j<(pos[3]-pos[1]);j++)
    60.                                         printf("GO RIGHT
    61. ");
    62.                         }
    63.                         printf("PRESS %c
    64. ",input[i+1]);
    65.                
    66.        
    67.         }
    68.        
    69. }
    70.  

  •  

    Write a program to read a four digit integer and print the sum of its digits.Write a program that reads a floating point number and then displays the right-most digit of the integral part of the number.

    gaurav kumar jaiswal

    • Aug 31st, 2014

    Write a c++ program to the sum and product of digits of an integers

    karuna gaur

    • Apr 15th, 2013

    456 sum is 15

    Code
    1. int sumDigits(int n) {
    2. int sum = 0;
    3.  
    4. while( n > 0 ) {
    5. sum += (n % 10); // add last digit of n to sum
    6. n /= 10; // divide n by 10 to "chop off" the last digit
    7. }
    8.  
    9. return sum;
    10.  
    11. getch();
    12. }

  •  

    Functions

    1.One foot equals 12 inches. Design a function named
    feetTolnches that accepts a number of feet as an argument, and returns the number of inches in that many feet. Use the function in a program that prompts the user to enter a number of feet and then displays the number of inches in that many feet.

    2.Rainfall Statistics
    Design a program that lets the user enter the total rainfall...

    George

    • Jul 29th, 2014

    In Haskell (please excuse syntax highlighting; they dont have it for this language):"css -- feetToInches.hs module Main where feetToInches :: Num a => a -> a feetToInches = (*12) ...

  •  

    Logic and Design

    Number Analysis Program

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data:

    • The lowest number in the array
    • The highest number in the array
    • The total of the numbers in the array
    • The average of the numbers in the array

    tnguyen25

    • Jun 2nd, 2014

    Thank you for your question. "c# private static int lowestNumberInArray(int[] numbers) { if (numbers.Length < 0) throw new ArgumentExce...

  •  

    Analysis Number Design Flow chart

    Number analysis program design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display the following data: the lowest number in the array,the highest number in the array and the total of the numbers in the array...

    Michael Brown

    • Apr 1st, 2014

    "c numlist = [-7,1,2,45289, 7,5,9,7,4,-10,34,234345678,32,12,1566,0,8,5,4,2] sum = 0 current = numlist[0] high = numlist[0] low = numlist[0] current = numlist[0] for i in rang...

  •  

    Arrays

    Design a flow chart for program that displays the number of days in each month. the program should have two parllel arrays 12 element string array that is initialized with the names of the month, and 12 element integer array that is initialized the number of days in each month.

    Cassandra Blackburn

    • Sep 9th, 2013

    Jan Month have 31 Days Feb Month have 28 days March Month have 31 Days April Month have 30 Days
    May Month have 31 days June Month have 30 Days July Month have 31 days Aug Month have 31 Days
    Sept Month have 30 Days Oct Month have 31 Days Nov Month have 30 days Dec Month have 31 Days

    Ponni Vaithiyanathan

    • Aug 20th, 2013

    Jan Month have 31 Days feb Month have 28 Days March Month have 31 Days April Month have 30 Days May Month have 31 Days June Month have 30 Days july Month have 31 Days Aug Month have 30 Days sep Month ...

  •  

    Efficient algorithm to print count and possible string outcomes of a given input string

    Write an Efficient algorithm to print count and possible string outcomes of a given input string by retaining order and considering all characters during this process

    Problem: given a input string as "0000" and following input scheme for the zeroes, print the possible outcomes by retaining order of the characters. input scheme: a "0" b "00" c "000" d "0000" example: "aaaa" is one string...

    cfphpflex@gmail.com

    • Mar 21st, 2013

    1. get string length 2. print length 3. for string 0000, its easy: 4. look at 0000 and quickly understand that each 0 in the string can only have 3 other possible 0 s to compare against and get a diff...

  •  

    Reverse a sting using loop in php

    Hi , when I reverse a string using loop in php like

    php$str="navin";
    $rstr="";
    $len=strlen($str);
    for($i=$len-1;$i>=0;$i--)
    {
    $rstr.=$str[$i];
    }
    echo $rstr;

    It work but I want to know why we use .dot(.) $rstr.=$str[$i]; over here thanks in advance

    Emiliano Gaytan

    • Mar 21st, 2013

    to concat, . operator concats left & right values; Google it for more info "php $myVar = 2; // declare variable in php print_r($myVar . ""); //print on screen your variable w htm...

  •  

    If else in c++

    Hi guys ,

    in c++ programming (if) when we use "=" isntead of "==" compiler behave the same ... Do u know why compiler Behave like this ??

    Tnx

    vinodh

    • Dec 11th, 2012

    In the first if condition want to place double equal.then it will treat as condition.otherwise it will treat as declaration

  •  

    Cass to Track Number of Instances

    Design a class that will keep track of number of instances that have been instantiated. Make this class thread safe.

    Dearsi

    • Feb 1st, 2012

    Here

    Code
    1. 1       public class Utility
    2. 2       {
    3. 3           public Utility()
    4. 4           {
    5. 5               InstanceCount++;
    6. 6           }
    7. 7        
    8. 8           public static int InstanceCount;
    9. 9       }

  •  

    How to write Spiral matrix program?

    ashoknaina

    • Dec 20th, 2011

    Code
    1. #include<stdio.h>
    2. main()
    3. {
    4. int a[20][20],i,j,n,m,p,q,k=0;
    5. Enter Order Of matrix");
    6. scanf("%d%d",&m,&n);
    7. for(i=1;i<=m;i++)
    8. for(j=1;j<=n;j++)
    9.     scanf("%d",&a[i][j]);
    10.  
    11. p=m;
    12. q=n;
    13. i=j=1;
    14.  
    15. while(k<p*q)
    16. {
    17.     for(;j<=n&&k<p*q;j++)
    18.     {
    19.         printf("%d ",a[i][j]);
    20.         k++;
    21.     }
    22.     j--;  
    23.     i++;
    24.     for(;i<=m && k<p*q;i++)
    25.     {
    26.         printf("%d ",a[i][j]);
    27.         k++;
    28.     }
    29.     i--;
    30.     j--;    
    31.     for(;j>=i-m+1 && k<p*q;j--)
    32.     {
    33.         printf("%d ",a[i][j]);
    34.         k++;
    35.     }    
    36.     j++;
    37.     i--;
    38.     for(;i>1 && k<p*q;i--)
    39.     {
    40.         printf("%d ",a[i][j]);
    41.         k++;
    42.     }
    43.     if(k<p*q)
    44.     {
    45.         j++;
    46.         i++;
    47.         n--;
    48.         m--;
    49.     }
    50. }
    51. }

  •  

    Case sensitive

    Why the programing language are case sensitive as is not for user friendly.

    lavanyats

    • Jul 27th, 2008

    When a PL is case sensitive, the number of possible keywords/ variable names permissible is increased. Also - more important reason - program readability is improved - we use caps for macros, have different naming conventions based on case sensitivity and so on.

Showing Questions 1 - 20 of 38 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page:

 

Have Interview Question?

Please select the most appropriate category and mention a brief question title along with clear question details.

Ask Question

Login to Ask Question or Register your free account   

Name:
Email:
Category :
Sub Category :
Question Title:
Question in Detail :
Job Role (Optional) :
Company (Optional) :
 

Optional Features

Register at GeekInterview

Register me.

Subscribe to GeekInterview Newsletter

Yes, Subscribe me to Interview & Career Tips