Posts

Showing posts from July, 2024

Top Interview Questions for Freshers

 Are you preparing for an upcoming interview? Want to know the most common interview questions and how to answer them? Look no further! This blog post will provide you with the top interview questions, categorized by type, along with tips and examples to help you prepare. Introduction and Icebreakers 1. Can you tell me a little about yourself? 2. How did you hear about this position? 3. What do you know about our company? Career Goals and Motivation 1. Where do you see yourself in five years? 2. What are your long-term career goals? 3. Why do you want to work for our company? Job Skills and Experience 1. What are your strengths and weaknesses? 2. Can you give an example of a project you managed from start to finish? 3. How do you handle stress and pressure in the workplace? Behavioral Questions 1. Tell me about a time when you overcame a difficult challenge. 2. Can you describe a situation where you had to work with a difficult team member? 3. How do you handle feedback or construc...

Top 10 Tips for acing any Job Interview

  Are you preparing for an upcoming interview? Look no further! This blog post will provide you with valuable tips and tricks to help you ace your next interview. 1. Research, Research, Research - Learn about the company's mission, values, and products. - Review the company's website, social media, and recent news articles. - Understand the company's goals and challenges. 2. Review the Job Description - Study the job description and requirements. - Prepare examples of how your skills and experiences match the job. - Practice answering behavioral interview questions. 3. Prepare Your Resume and Portfolio - Make sure your resume is updated and tailored to the job. - Bring multiple copies of your resume and portfolio to the interview. - Highlight your achievements and relevant projects. 4. Practice Your Responses - Prepare answers to common interview questions. - Practice your responses with a friend or family member. - Use the STAR method to structure your answers. 5. Dress to...

Program to find Factorial of a Number

Image
FACTORIAL: The factorial of a number, is the product of all positive integers less than or equal to n. It's calculated by multiplying all the integers from 1 to n, in order. PROGRAM: #include <stdio.h> int main() {     int i,n, fact=1;     printf("Enter a number: ");     scanf("%d",&n);     for (i=1;i<=n;i++)     fact=fact*i;     printf("Factorial of %d is %d.",n,fact);     return 0; }   OUTPUT: TIME COMPLEXITY: The time complexity is O(n) because the loop iterates from 1 to n, performing n iterations. This means the time taken to execute the program increases linearly with the input size n. SPACE COMPLEXITY: The space complexity is O(1) because the program uses a fixed amount of memory to store the variables fact and i, regardless of the input size n. The memory usage doesn't grow with the input size, so it's constant.

Program to check Prime number or not

Image
PRIME NUMBER: A prime number is a positive integer that is divisible only by itself and 1. In other words, it is a number that is not divisible by any other number except for 1 and itself. For example, 2, 3, 5, 7, 11, and 13 are all prime numbers. PROGRAM (METHOD 1):  #include <stdio.h> int main() {     int i,n,flag=0;     printf("Enter a number:");     scanf("%d",&n);     for(i=2;i<n;i++)     if(n%i==0)     flag++;     if(flag==0)     printf("%d is a prime number",n);     else     printf("%d is not a prime number",n);     return 0; } TIME COMPLEXITY: The time complexity is O(n) because the for loop iterates from 2 to n-1, and the number of iterations grows linearly with the input size n. SPACE COMPLEXITY: The program uses a constant amount of extra space to store the variables i and n, which doesn't depend on the size of the input. Therefore, the space complex...

Program to Reverse a Number

Image
REVERSE A NUMBER: This program takes an integer input from the user, reverses it, and then prints the reversed number. For example, if the user enters 123, the program will print 321. PROGRAM:   #include <stdio.h> #include <string.h> int main() {     int n,rem,rev=0;     printf("Enter a number: ");     scanf("%d",&n);     while(n!=0)     {         rem=n%10;         rev=rev*10+rem;         n=n/10;     }     printf("Reverse of the number is: %d",rev); } TIME COMPLEXITY: The time complexity is indeed O(log n) because the while loop iterates through each digit in the input number, and the number of digits is proportional to the logarithm of the number.  SPACE COMPLEXITY: The program uses a constant amount of extra space to store the variables rem, rev, and n, which doesn't depend on the size of the input number. Therefore, the space comp...

Check a number is palindrome or not

Image
PALINDROME: A palindrome is a word, phrase, or sequence that reads the same backward as forward.  A number palindrome is a numerical palindrome, where the digits read the same when reversed. For example, 12321 is a palindrome whereas 12345 is not a palindrome. PROGRAM: #include <stdio.h> int main() {     int n,m,rem,rev=0;     printf("Enter any number: ");     scanf("%d",&n);     m=n;     while(n!=0)     {         rem=n%10;         rev=rev*10+rem;         n=n/10;     }     if(rev == m)     printf("%d is a palindrome", m);     else     printf("%d is not a palindrome",m);     return 0; } TIME COMPLEXITY: The time complexity of the program is indeed O(log n) because the number of iterations in the while loop is proportional to the number of digits in the input number 'n'. As the number of digits in...

Program to check leap year

Image
LEAP YEAR: A leap year is a year that is divisible by 4, but not by 100, unless it is also divisible by 400. This means that years like 2024, 2020, and 2016 are leap years, but 2100 is not. PROGRAM: include <stdio.h> int  main() {     int year;     printf("Enter the year: ");     scanf("%d",&year);     if((year%4==0 && year%100!=0) || year%400==0)     {     printf("%d is a leap year", year);     }     else     {     printf("%d is not a leap year", year);     }     return 0; } TIME COMPLEXITY: The time complexity of this program is O(1) because the program only performs a fixed number of operations regardless of the input size. The if- else statement and the printf statements are executed once each, making the time complexity O(1). SPACE COMPLEXITY: The space complexity is O(1) because the program only uses a constant amount of memory to stor...

Swap two numbers without using third variable

Image
SWAPPING TWO NUMBERS WITHOUT USING A THIRD VARIABLE There are two common ways to swap two numbers without using a third variable: PROGRAM 1 (Using addition and Subtraction): #include <stdio.h> int main() {     int a,b;     printf("enter the value of a: ");     scanf("%d",&a);     printf("enter the value of b: ");     scanf("%d",&b);     printf("Before swapping, a=%d b=%d.",a,b);     a=a+b;     b=a-b;     a=a-b;     printf("\nAfter swapping, a=%d b=%d.",a,b);     return 0; } PROGRAM 2 (Using Bitwise XOR): #include <stdio.h> int main() {     int a,b;     printf("enter the value of a: ");     scanf("%d",&a);     printf("enter the value of b: ");     scanf("%d",&b);     printf("Before swapping, a=%d b=%d.",a,b);     a=a^b;     b=a^b;     a=a^b;     printf("...