Programming Interview Questions

Sub Category
Questions
Answers
Last Updated
60
267
Nov 27th, 2018
23
37
Jul 14th, 2017
26
41
Apr 5th, 2018
27
29
Jul 25th, 2017
66
248
May 21st, 2018
101
523
Mar 25th, 2018
25
86
Sep 11th, 2018
63
78
Nov 21st, 2017
21
27
Apr 27th, 2017
46
125
Feb 3rd, 2016

Showing Questions 41 - 42 of 42 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page:
  •  

    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.

    sravani reddy

    • Sep 21st, 2017

    Code
    1. #include<stdio.h>
    2. int main()
    3. {
    4. int rem,sum=0,n;
    5. printf("enter the number:");
    6. scanf("%d
    7. ",&n);
    8. while(n!=0)
    9. {
    10. rem=n%10;
    11. sum=sum+rem;
    12. n=n/10;
    13. }
    14. printf("the sum of digits of a number is %d",sum);
    15. return 0;
    16. }

    Shasan

    • Mar 29th, 2016

    "c# public static int Sum() { int n = 1235678; int n1 = 0; int f = 0; while (n!= 0) { ...

  •  

    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

    Teja

    • Oct 8th, 2017

    int arr[] = {4,2,6,1,7,12,10,11}; int min= arr[0]; int max= arr[0]; int total = 0; int avg; for(int i=0; i arr[i]) { min = arr[i]; } else if(max < arr[i]) { max = arr[i];...

    Shubhangi

    • Oct 5th, 2017

    I inserted a code but how to get exact decimal point answer for avg,I didnt get .

    Code
    1. #include<stdio.h>
    2. main()
    3. {
    4. int arr[10];
    5. int i,size;
    6. size=sizeof(arr)/sizeof(arr[0]);
    7. printf("enter the array elemrnt......
    8. ");
    9.  
    10. for(i=0;i<size;i++)
    11. //scanf("%d",&arr[i]);
    12. arr[i]=rand()%100;
    13.  
    14. for(i=0;i<size;i++)
    15. printf("%d      ",arr[i]);
    16. ");
    17.  
    18. //lowest number....
    19. int temp=arr[0];
    20. for(i=1;i<size;i++)
    21. {
    22. if(temp>arr[i])
    23. temp=arr[i];
    24. else
    25. continue;
    26. }
    27. printf("lowest element=%d
    28. ",temp);
    29. //highewst numer
    30.  temp=arr[0];
    31. for(i=1;i<size;i++)
    32. {
    33. if(temp<arr[i])
    34. temp=arr[i];
    35. else
    36. continue;
    37. }
    38. printf("highest element=%d
    39. ",temp);
    40.  
    41. //toatal of numbers
    42. int sum =0;
    43. for(i=0;i<size;i++)
    44. {
    45. sum=sum+arr[i];
    46. }
    47. printf("total of an array:%d
    48. ",sum);
    49. //average
    50. int avg;
    51. avg=sum/size;
    52. printf("average=%d
    53. ",avg);
    54.  
    55. }
    56.  

Showing Questions 41 - 42 of 42 Questions
First | Prev | Next | Last Page
Sort by: 
 | 
Jump to Page: