The Coding Bytes | Latest Jobs & Internship | Placement | Off Campus | IT Jobs | Abhishek Parmar
Open in Telegram
Campus Preparation, Best Resources, Jobs & Tips from selected students Website : www.thecodingbytes.com Admin : @contact_adminn Youtube : https://www.youtube.com/c/TheCodingBytesOfficial Instagram https://www.instagram.com/thecodingbytes
Show more7 894
Subscribers
No data24 hours
-97 days
-4830 days
Posts Archive
Practice Question
Sum with Five and Eight
Given a list of numbers separated with a comma.
The numbers 5 and 8 are present in the list. Assume that 8 always comes after 5.
Case 1: num1 -> Add all numbers which do not lie between 5 and 8 in the Input List.
Case 2: num2 -> Numbers formed by concatenating all numbers from 5 to 8 in the list.
Output: Sum of num1 and num2
Example: 3,2,6,5,1,4,8,9
Num1 : 3+2+6+9 =20
Num2: 5148
Output=5148+20 = 5168
Solution:
https://youtu.be/pt1pCQG28wY
Practice Question for placement:
OTP Generation:
Input Format: 134567
Output Format: 1925
Explanation: Take the string of numbers and generate a four-digit OTP such that: 1. If number is odd then square it 2. If the number is even then ignore it
So in the input number 1,3,5,7 are odd. Square each digits we will get 192549 now print first four digits as output i.e. 1925
If in case not possible then print -1
Example:
Input Format 1: 222222
Output Format 1: -1
Input Format 2: 9744
Output Format 2: 8149
Solution:
https://youtu.be/Y1XKkUoF06Q
Telegram :
@thecodingbytes
@placements2021batch
Instagram:
Instagram
https://www.instagram.com/thecodingbytes
"Enter the number \n");
scanf("%ld", &num);
temp = num;
while (num > 0)
{
digit = num % 10;
sum = sum + digit;
num /= 10;
}
printf("Given number = %ld\n", temp);
printf("Sum of the digits %ld = %ld\n", temp, sum);
}
Question 13):
Write a program to find Sum of N natural numbers
Solution :
#include <stdio.h>
int addNumbers(int n);
int main() {
int num;
printf("Enter a positive integer: ");
scanf("%d", &num);
printf("Sum = %d", addNumbers(num));
return 0;
}
int addNumbers(int n) {
if (n != 0)
return n + addNumbers(n - 1);
else
return n;
}
Question 14):
Write a program to find Sum of numbers in a given range
Solution :
#include<stdio.h>
int main()
{
int start, end;
scanf(ā%dā,&start);
scanf(ā%dā,&end);
int i, sum = 0;
for(i = start; i <= end; i++)
{
sum = sum + i;
}
printf(ā%dā,sum);
return 0;
}
Question 15):
Write a program to reverse a given number
Solution :
Reverse an Integer
#include <stdio.h>
int main() {
int n, rev = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while (n != 0) {
remainder = n % 10;
rev = rev * 10 + remainder;
n /= 10;
}
printf("Reversed number = %d", rev);
return 0;
}
Question 16) :
Write a program to find LCM of two numbers
Solution :
#include <stdio.h>
int main() {
int n1, n2, min;
printf("Enter two positive integers: ");
scanf("%d %d", &n1, &n2);
min = (n1 > n2) ? n1 : n2;
while (1) {
if (min % n1 == 0 && min % n2 == 0) {
printf("The LCM of %d and %d is %d.", n1, n2, min);
break;
}
++min;
}
return 0;
}
return 0;
}
Question 17):
Write a program to identify if the number is Strong number or not
Solution :
#include<stdio.h>
int main() {
int num,i,f,r,sum=0,temp;
printf("Enter a number: ");
scanf("%d",&num);
temp=num;
while(num) {
i=1,f=1;
r=num%10;
while(i<=r) {
f=f*i;
i++;
}
sum=sum+f;
num=num/10;
}
if(sum==temp)
printf("%d is a strong number",temp); else
printf("%d is not a strong number",temp);
return 0;
}
Question 18):
Write a program to identify if the number is Perfect number or not
Solution :
# include <stdio.h>
int main()
{
int i, Number, Sum = 0 ;
printf("\n Please Enter any number \n") ;
scanf("%d", &Number) ;
for(i = 1 ; i < Number ; i++)
{
if(Number % i == 0)
Sum = Sum + i ;
}
if (Sum == Number)
printf("\n %d is a Perfect Number", Number) ;
else
printf("\n%d is not the Perfect Number", Number) ;
return 0 ;
}
Question 19):
Write a program to find Power of a number
Solution :
#include <stdio.h>
int main() {
int base, exp;
long long result = 1;
printf("Enter a base number: ");
scanf("%d", &base);
printf("Enter an exponent: ");
scanf("%d", &exp);
while (exp != 0) {
result *= base;
--exp;
}
printf("Answer = %lld", result);
return 0;
}
Question 20):
Write a program to find the Factors of a number
Solution :
#include <stdio.h>
int main() {
int num, i;
printf("Enter a positive integer: ");
scanf("%d", &num);
printf("Factors of %d are: ", num);
for (i = 1; i <= num; ++i) {
if (num % i == 0) {
printf("%d ", i);
}
}
return 0;
}
Instagram :
https://www.instagram.com/thecodingbytes
Facebook :
https://www.facebook.com/thecoding.bytes.9
Telegram :
Official channel :
@thecodingbytes
Batch 2021 : @placementdiscussions2021
Infytq :
@infytqfinals
Practice Questions for placement
Question 1) :
Write a program to identify if the character is a vowel or consonant
Solution :
#include <stdio.h>
int main() {
Ā Ā char c;
Ā Ā int lowercase, uppercase;
Ā Ā printf("Enter an alphabet: ");
Ā Ā scanf("%c", &c);Ā Ā Ā
Ā Ā lowercase = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
Ā Ā uppercase = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
Ā Ā if (lowercase || uppercase)
Ā Ā Ā Ā printf("%c is a vowel", c);
Ā Ā else
Ā Ā Ā Ā printf("%c is a consonant", c);
Ā Ā return 0;
}
Question 2) :
Write a program to identify if the character is an alphabet or not
Solution :
#include <stdio.h>
int main() {
Ā Ā char c;
Ā Ā printf("Enter a character: ");
Ā Ā scanf("%c", &c);
Ā Ā if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
Ā Ā Ā Ā printf("%c is an alphabet.", c);
Ā Ā else
Ā Ā Ā Ā printf("%c is not an alphabet.", c);
Ā Ā return 0;
}
Question 3) :
Write a program to find ASCII values of a characterĀ
Solution :
#include <stdio.h>
int main() {Ā Ā
Ā Ā char c;
Ā Ā printf("Enter a character: ");
Ā Ā scanf("%c", &c);Ā Ā
Ā Ā printf("ASCII value of %c = %d", c, c);
Ā Ā Ā
Ā Ā return 0;
}
Question 4):
Write a program to find Number of digits in an integerĀ
Solution :
#include <stdio.h>
int main() {
Ā Ā long long n;
Ā Ā int count = 0;
Ā Ā printf("Enter an integer: ");
Ā Ā scanf("%lld", &n);
Ā Ā while (n != 0) {
Ā Ā Ā Ā n /= 10;Ā Ā Ā // n = n/10
Ā Ā Ā Ā ++count;
Ā Ā }
Ā Ā printf("Number of digits: %d", count);
}
QuestionĀ 5):
Write a program to find Factorial of a number
Solution :
#include <stdio.h>Ā
int main()
{
Ā int c, n, f = 1;
Ā printf("Enter a number to calculate its factorial\n");
Ā scanf("%d", &n);
Ā for (c = 1; c <= n; c++)
Ā Ā f = f * c;
Ā printf("Factorial of %d = %d\n", n, f);
Ā return 0;
}
Question 6):Ā
Write a program to find Fibonacci series up to nĀ
Solution :
include <stdio.h>
int main() {
Ā Ā int i, n, t1 = 0, t2 = 1, nextTerm;
Ā Ā printf("Enter the number of terms: ");
Ā Ā scanf("%d", &n);
Ā Ā printf("Fibonacci Series: ");
Ā Ā for (i = 1; i <= n; ++i) {
Ā Ā Ā Ā printf("%d, ", t1);
Ā Ā Ā Ā nextTerm = t1 + t2;
Ā Ā Ā Ā t1 = t2;
Ā Ā Ā Ā t2 = nextTerm;
Ā Ā }
Ā Ā return 0;
}
Question 7) :
Write a program to identify of the a number is positive or negativeĀ
Solution :
#include <stdio.h>
int main()
{
Ā Ā int num;
Ā Ā
Ā Ā printf("Enter any number: ");
Ā Ā scanf("%d", &num);
Ā Ā Ā
Ā Ā if(num > 0)
Ā Ā {
Ā Ā Ā Ā printf("Number is POSITIVE");
Ā Ā }
Ā Ā if(num < 0)
Ā Ā {
Ā Ā Ā Ā printf("Number is NEGATIVE");
Ā Ā }
Ā Ā if(num == 0)
Ā Ā {
Ā Ā Ā Ā printf("Number is ZERO");
Ā Ā }
Ā Ā return 0;
}
Question 8):
Write a program to identify if the number is even or odd
Solution :
nclude <stdio.h>
int main() {
Ā Ā int num;
Ā Ā printf("Enter an integer: ");
Ā Ā scanf("%d", &num);
Ā Ā Ā
Ā Ā (num % 2 == 0) ? printf("%d is even.", num) : printf("%d is odd.", num);
Ā Ā return 0;
}
Question 9):
Write a program to find Area of a circleĀ
Solution :
#include<stdio.h>
int main() {
Ā Ā float radius, area;
Ā Ā printf("\nEnter the radius of Circle : ");
Ā Ā scanf("%d", &radius);
Ā Ā area = 3.14 * radius * radius;
Ā Ā printf("\nArea of Circle : %f", area);
Ā Ā return (0);
}
Question 10):
Write a program to find Area of a rectangle
Solution :
#include <stdio.h>Ā Ā
int main()Ā Ā
{Ā Ā
Ā Ā int width=5;Ā Ā
Ā Ā int height=10;Ā Ā
Ā Ā int area=width*height;Ā Ā
Ā Ā printf("Area of the rectangle=%d",area);Ā Ā
}Ā Ā
Question 11):Ā
Write a program to find Area of a TriangleĀ
Solution :
#include <stdio.h>
#include <math.h>
int main()
{
Ā double a, b, c, s, area;
Ā printf("Enter sides of a triangle\n");
Ā scanf("%lf%lf%lf", &a, &b, &c);
Ā s = (a+b+c)/2; // Semiperimeter
Ā area = sqrt(s*(s-a)*(s-b)*(s-c));
Ā printf("Area of the triangle = %.2lf\n", area);
Ā return 0;
}
Question 12):
Write a program to find Sum of digits of a number
Solution :
#include <stdio.h>
void main()
{
Ā Ā long num, temp, digit, sum = 0;
Ā Ā printf(
Practice Question
Write a program to validate PAN Card number
Given a string of alphanumeric characters, the task is to check whether the string is valid PAN (Permanent Account Number) Card number or not.
The valid PAN Card number must satisfy the following conditions:
1)It should be ten characters long.
2)The first five characters should be any upper case alphabets.
3)The next four-characters should be any number from 0 to 9.
4)The last(tenth) character should be any upper case alphabet.
Examples:
Input: : BNZAA2318J
Output: Valid PAN no
Note : You can use any language of your choice
Comment your solution below!!
Placement Guidance
All you need to learn for Campus Placements:
1) Aptitude( Quants)
2) Reasoning
3) English Grammer ( Vocabs and Basic english grammer rules of Subject verb agreement, Noun, pronoun etc)
4) Any one procedural Programming Language for Non-CS/IT (C Highly recommended)
and any one Object oriented programming language (Java, CPP, Python ) for CS/IT students
5) Communication Skills ( for Group discussion and interview )
6) Data Structures and Algorithm ( Highly recommended) :
We upload daily quiz of data structures on instagram. You can follow us at www.instagram.com/thecodingbytes
on Instagram.
All these things would help you to clear online test as well as interview also.
Some Tips:
1) Make atleast projects ( For CS/IT : any application and For Non-CS /IT : anthing relates with your respective branches)
2) Write only those things in your resume that you are prepared for, do not write anything word that you don't have
3) Read newspaper as it will help you to be aware of current news, you will get new words daily and also it can help you to perform well in Group Discussions.
4) Read books (not subjective) if you can. As you can learn a lot of vocabs from book.
5) Try to code on daily basis and solve as many problems as you can
Please share this with your friends so that they can also be aware of the things while preparing for Placements and if you have any doubt you can ask on instagram.
Thankyou!!
Happy Learning!!!
Instagram
https://www.instagram.com/thecodingbytes/
Facebook :
https://m.facebook.com/thecodingbytes.Official/
Telegram
@thecodingbytes
@placementdiscussions2021
Output of following python code
X=1-20-1992
print(type(X))
Which operator is used to search for specified pattern in a column? ( SQL )
We completed 1000 subscribers on YouTube and 1000 followers on instagram ...
Thankyou everyone for your love and support!!
Which funntion would you use to convert 1.98 to 1
For InfyTQ participantsš
Prefix is just reverese of Postfix
