Accenture Company Coding Questions Set 3 | Sum of all multiples | Print all the intermediate palindrome numbers

Hello friends, I hope you all are doing great. In this post today we will learn to solve the 2 coding questions which is being asked by the Accenture company recently. If you are preparing for selection in any company then this post will help you definitely.

Lets Start

1.Sum of all multiples

Problem: Write a program in C to display the table of a number and print the sum of all the multiples in it.

Test Cases:

Test Case 1:
Input:
5
Expected Result Value:
5, 10, 15, 20, 25, 30, 35, 40, 45, 50
275

Test Case 2:
Input:
12
Expected Result Value:
12, 24, 36, 48, 60, 72, 84, 96, 108, 120
660

/*solution in C*/
#include<stdio.h>
int main()
{
	int no,sum=0;
	printf("Enter any number\n");
	scanf("%d",&no);
	for(int i=1; i<= 10;i++)
	{
		printf("%d ",i*no);
		sum+=(i*no);
	}
	printf("\n%d",sum);
}
/*
Enter any number
5
5 10 15 20 25 30 35 40 45 50
275
*/

2.Print all the intermediate palindrome  numbers

Question: Write a program in C such that it takes a lower limit and upper limit as inputs and print all the intermediate palindrome numbers.

Test Cases:

TestCase 1:
Input :
10 , 80
Expected Result:
11 , 22 , 33 , 44 , 55 , 66 , 77.

Test Case 2:
Input:
100,200
Expected Result:
101 , 111 , 121 , 131 , 141 , 151 , 161 , 171 , 181 , 191.

/*solution in C*/
#include<stdio.h>
int main()
{
	int s,e,rev=0,no,r;
	printf("Enter starting\n");
	scanf("%d",&s);
	printf("Enter ending\n");
	scanf("%d",&e);
	
	for(int i=s;i<=e;i++)
	{
	  no=i;
	  rev=0;
		while(no!=0)
	  {
		r=no%10;
		rev=rev*10+r;
		no=no/10;		
	  }
	  if(rev==i)
	  printf("%d ",i);
	}
	
	
}
/*
Enter starting
100
Enter ending
200
101 111 121 131 141 151 161 171 181 191
*/

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 

If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 

Thanks

Post a Comment

0 Comments