INTERVIEW QUESTIONS IN "C PROGRAMMING "LANGUAGE

Posted by Tushar Bedekar


TABLE OF CONTENTS

CHAPTER 1: Variables & Control Flow

1. What is the difference between declaring a variable and defining a variable? 
2. What is a static variable? 
3. What is a register variable? 
4. Where is an auto variable stored? 
5. What is scope & storage allocation of extern and global variables? 
6. What is scope & storage allocation of register, static and local variables?
7. What are storage memory, default value, scope and life of Automatic and Register storage class? 
8. What are storage memory, default value, scope and life of Static and External storage class? 
9. What is the difference between 'break' and 'continue' statements?
10. What is the difference between 'for' and 'while' loops?

solution:-Download link


CHAPTER 2: Operators, Constants & Structures


1. Which bitwise operator is suitable for checking whether a particular bit is ON or OFF? 
2. Which bitwise operator is suitable for turning OFF a particular bit in a number? 
3. What is equivalent of multiplying an unsigned int by 2: left shift of number by 1 or right shift of number by
1? 
4. What is an Enumeration Constant?
5. What is a structure? 
6. What are the differences between a structure and a union? 
7. What are the advantages of unions? 
8. How can typedef be to define a type of structure? 
9. Write a program that returns 3 numbers from a function using a structure. 
10. In code snippet below: 
struct Date {
 int yr;
 int day;
 int month;
} date1,date2;
date1.yr = 2004;
date1.day = 4;
date1.month = 12;
Write a function that assigns values to date2. Arguments to the function must be pointers to the
structure, Date and integer variables date, month, year. 

solution:-Download link

CHAPTER 3: Functions


1. What is the purpose of main() function? 
2. Explain command line arguments of main function? 
3. What are header files? Are functions declared or defined in header files ? 
4. What are the differences between formal arguments and actual arguments of a function? 
5. What is pass by value in functions? 
6. What is pass by reference in functions? 
7. What are the differences between getchar() and scanf() functions for reading strings? 
8. Out of the functions fgets() and gets(), which one is safer to use and why? 
9. What is the difference between the functions strdup() and strcpy()? 

solution:-coming-soon


CHAPTER 4: Pointers


1. What is a pointer in C? 
2. What are the advantages of using pointers? 
3. What are the differences between malloc() and calloc()? 
4. How to use realloc() to dynamically increase size of an already allocated array? 
5. What is the equivalent pointer expression for referring an element a[i][j][k][l], in a four dimensional array?
6. Declare an array of three function pointers where each function receives two integers and returns float. 
7. Explain the variable assignment in the declaration
int *(*p[10])(char *, char *);
8. What is the value of 
sizeof(a) /sizeof(char *)
in a code snippet:
char *a[4]={"sridhar","raghava","shashi","srikanth"};
9. (i) What are the differences between the C statements below: 
char *str = "Hello";
char arr[] = "Hello";
(ii) Whether following statements get complied or not? Explain each statement. 
arr++;
*(arr + 1) = 's';
printf("%s",arr);

solution:-coming-soon


CHAPTER 5: Programs


1. Write a program to find factorial of the given number. 
2. Write a program to check whether the given number is even or odd. 
3. Write a program to swap two numbers using a temporary variable. 
4. Write a program to swap two numbers without using a temporary variable. 
5. Write a program to swap two numbers using bitwise operators. 
6. Write a program to find the greatest of three numbers. 
7. Write a program to find the greatest among ten numbers. 
8. Write a program to check whether the given number is a prime. 
9. Write a program to check whether the given number is a palindromic number. 
10.Write a program to check whether the given string is a palindrome. 
11.Write a program to generate the Fibonacci series. 
12.Write a program to print "Hello World" without using semicolon anywhere in the code. 
13.Write a program to print a semicolon without using a semicolon anywhere in the code. 
14.Write a program to compare two strings without using strcmp() function. 
15.Write a program to concatenate two strings without using strcat() function. 
16.Write a program to delete a specified line from a text file. 
17.Write a program to replace a specified line in a text file. 
18.Write a program to find the number of lines in a text file. 
19.Write a C program which asks the user for a number between 1 to 9 and shows the number. If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input. 
20.Write a program to display the multiplication table of a given number.

solution:-coming-soon
Read More

Try If You Can

Posted by Tushar Bedekar




  • Note:- You Can Also Mail Your Responses at Contact us
  • The responses May be Generated either using GCC or Turbo C compiler.It does`t matter but the correctness of responses is required.
  • Download Turbo C HERE
  • Online Compiler HERE

Read More

C Program to Print 1-10 numbers without using Conditional Loops

Posted by Tushar Bedekar
Print 1-10 numbers without using Conditional Loop i.e without using
  • for Loop
  • while Loop
  • do-while Loop


#include<stdio.h>

void printNumber(int value) {
   int i;
   printf("%d\n", value);          //The Following programme is written using the concept of recursion
   i = value + 1;

   if (i > 10)
      return;
   printNumber(i);
}

void main() {
   printNumber(1);
}
Read More

Algorithms and Flowchart in C Programming

Posted by Tushar Bedekar
                              

                                           Algorithms:-
A sequential solution of any program that written in human language,called algorithm.
Algorithm is first step of the solution process, after the analysis of problem, programmer write the algorithm of that problem.
Example of Algorithms:
Q. Write a algorithms to find out number is odd or even?
Ans. 
step 1 : start
step 2 : input number
step 3 : rem=number mod 2
step 4 : if rem=0 then
               print "number even"
           else
               print "number odd"
           end if
step 5 : stop



                                            Flowchart:-

1. Graphical representation of any program is called flowchart.

2. There are some standard graphics that are used in flowchart as following:








Q. Make a flowchart to input temperature, if temperature is less than 32 then print "below freezing" otherwise print  "above freezing"?
Ans.










Read More

How To Increase Internet Speed without the use of any software

Posted by Tushar Bedekar

Many times we find that our internet speed is slow and we get tired to use it for a long time. Now here is the solution. Actually.Actually what our PC or Our Laptop reserves some amount of the internet bandwidth(nearly 20% default). And now if we make this reserved band width to a zero than the internet speed can be increased by the certain amount.So in order to increase your internet speed just follow the steps given below:-

Steps:-


  • First of all open run just by pressing the keyboard shortcut(windows key +R)
  • Then enter the command given below:-                                              gpedit.msc
  • Now a windows opens having the name (local group policy editor)
  • In the left most corner it has been written (administrative temp lets)
  • Inside that administrative temp-lets click on the network.
  • Now in the right hand side window you will find QoS packet scheduler.
  • Now double click on that.
  • After Double clicking it you will find the option limit reversible bandwidth.
  • Again Double click on that.
  • you will find the option bandwidth limit (%) in which 20 or any other value is being written.
  • Make it zero and than click apply.
  • Now you have done.
  • Then restart your Browser you will find some speed has been increased.  

Screen Shots:-


http://www.allaboutcomputing.net/
 http://www.allaboutcomputing.net/

http://www.allaboutcomputing.net/
http://www.allaboutcomputing.net/

Warning:-

  • We are not responsible for any damages that may happened by using this Techniques. 
  • Use this guide at your own risk. We shall not have any liability or responsibility for whatever happens to you and your device by using the instructions in this guide.
  • The instructions provided in this tutorial for educational purpose only. There is no guarantee that these steps will work for your device.
  •  Applying this guide to any other device or any other model may produce many problems.
  • Read and Understand the whole tutorial first, before going to perform the steps.
  • At the same time this content is not to harm any one but it is only for educational purpose.


Read More

Fibonacci series by Recursion in c

Posted by Tushar Bedekar

Introduction:-

http://www.allaboutcomputing.net/
Recursion is the process of repeating items in a self-similar way. In other words recursion is a process in which a same set of a statement/expressions are executed large no of times in such a manner that after the execution of a certain set of a statement/expression, again the same set of a statement/expressions are being executed until the condition is satisfied. Generally this kind of a process takes place in the in functions in which a function calls itself. The following is the syntax of the recursive function:-
void recursion()
{
   recursion(); /* function calls itself */
}

int main()
{
   recursion();
}
http://www.allaboutcomputing.net/Actually most of the programming languages support recursion an C programming language is one of them i.e., a function to call itself. But while using recursion, programmers need to be careful to define an exit condition from the function, otherwise it will go in infinite loop.
Recursive function are very useful to solve many mathematical problems like to calculate factorial of a number, generating Fibonacci series, etc.

Program me:-


/* Fibonacci by Recursion */
#include<stdio.h>
http://www.allaboutcomputing.net/
int fib(int); int main() { printf("Type any value : "); printf("\nNth value: %d",fib(getche()-'0')); return 0; } int fib(int n) { if(n<=1) return n; return(fib(n-1)+fib(n-2)); }
Read More

C Programming to Explain Type Casting

Posted by Tushar Bedekar

Introduction:-

Type casting is a way to convert a variable from one data type to another data type. For example, if you want to store a long value into a simple integer then you can type cast long to int. You can convert values from one type to another explicitly using the cast operator as follows:


Program me:-

#include< stdio.h>
#include< conio.h>
int main( )
{
int n,i,j,fact;
float sum=0;
clrscr();
for(i=1; i<=7; i++) { fact=1; for(j=i; j>=1; j--)                       // to find the factorial
fact=fact*j;

sum=sum+(float)i/fact;
}
printf("\nSum : %f",sum);
getch();
return 0;
}

Read More

Modifiers in C Programming Language

Posted by Tushar Bedekar
C Programming Modifier
As We Have discussed in the last article about C Programming   the data types have some modifiers preceding them. The use of these modifiers changes the meaning of the base type.

The memory in the computer is organized in terms of units called bytes. One  byte consists of 8 bits and bit is a smallest unit of memory.

Need of Data Modifiers:

The Need of modifiers can be understood by the help of following.Let us take an example of a Program where we need to input the “Salary” of “Employees” in a team. This program will accept the salary as an input from user and then calculate the Income Tax of that user. We use “int” to store the Salary of the employee as we are assuming that the salary will be in “Whole Numbers”.
C Programming Modifier

An integer data type takes 2 Bytes of Memory and we are aware that the Salary of any of the employee can not be “Negative”. We are using “2 Bytes” to store the memory of an Employee and we can easily save 1 Byte over there by removing the “Signed Part” in the integer. This positive value can easily be stored in “1 Bye Int” This leads us to the user of Data Type Modifiers.

Types of Data Modifiers in C:

Basically c programming language consist of 3 basic modifiers.The modifiers are listed below :


Signed Type Modifier:



All data types are “signed” by default. Signed Data Modifier implies that the data type variable can store positive values as well as negative values.


For example, if we need to declare a variable to store temperature, it can be negative as well as positive.

C Programming Modifier
signed int temperature;


Or


int temperature;



Unsigned Type Modifier:



If we need to change the data type so that it can only store only store positive values, “unsigned” data modifier is used.


For example, if we need to declare a variable to store the salary of an employee as explained above, we will use “Unsigned” Data Qualifier here.


unsigned int salary;


Long Type Modifier:


Sometimes while coding a program, we need to increase the Storage Capacity of a variable so that it can store values higher than its maximum limit which is there as default. In such situations or programs, we need to make use of the “long” data type qualifier. “long” type modifier doubles the “length” of the data type when used along with it.

C Programming Modifier
For example, if we need to store the “annual turnover” of a company in a variable, we will make us of this type qualifier.


long int turnover;


This variable will take 4 Bytes in memory.



Short Type Modifier:



A “short” type modifier does just the opposite of “long”. If one is not expecting to see high range values in a program and the values are both positive & negative.

C Programming Modifier
For example, if we need to store the “age” of a student in a variable, we will make use of this type qualifier as we are aware that this value is not going to be very high.


short int age;


This variable will consume only 1 Byte in memory.



Example

We can apply the above mentioned modifiers to integer (int) and character (char) base types.


1. Integer Type Modifiers:



* We can use all the above mentioned Type Modifiers for int data type in C Language

* Short int and long int are also termed as short and long respectively.
* Int is signed & unsigned by default.


2. Character Type Modifiers:



* Variables of type char consume 1 byte in memory.

* Char can be signed or unsigned only.
* They have a range of -128 to 127 and 0 to 255 for signed & unsigned respectively.


3. Float Type & Double Type Modifier:



There are 3 types of float type modifiers as given below:

C Programming Modifier


* float

* double
* long double

Double is same as long float. Float type occupies 4 bytes of memory. Type double occupies 8 bytes. Long double occupies 10 bytes. The exception to this is long double, which modifies the size of the double data type to 10 bytes. Please note that in some compilers this has no effect.



Note: We may use long modifier with double data type but it cannot be used with float, i.e. long double is allowed but long float is not allowed because long float is equal to double.


For More Info Download:-

                                                                                                                                                                       
Tushar
                                                           
Read More

What is a Hard Drive and How it Works

Posted by Tushar Bedekar

What is a Hard Drive:-

Inside a hard rive
Almost all desktop computers as well as laptops have a hard drive inside them, but do you really know what they are? Many people when they hear the word hard drive, think that it refers to the computer as a whole. In reality, though, the hard drive is just one of many different pieces that comprise a computer. The hard drive is one of the most important parts of your computer because it is used as a long-term storage space for your data. What that means, is regardless of whether or not the computer is on, or you lose power, the data will still stay stored on this hard drive keeping it safe. 
A hard drive is an integral part of your computer as your operating system and all your data are typically stored there. In the majority of the situations, if you did not have a working hard drive, or the hard drive malfunctions, you would not be able to boot your computer into the operating system and would get an error. 

How hard drives work:

The very interesting thing is that every one wants to know that how the Hard Drive works and how the data gets stored permanently for a long time even if the power is off.

A hard drive consists of the following:


    hard drive
  • Magnetic platters - Platters are the round plates in the image above. Each platter holds a certain amount of information, so a drive with a lot of storage will have more platters than one with less storage. When information is stored and retrieved from the platters it is done so in concentric circles, called tracks, which are further broken down into segments called sectors.
  • Arm - The arm is the piece sticking out over the platters. The arms will contain read and write heads which are used to read and store the magnetic information onto the platters. Each platter will have its own arm which is used to read and write data off of it.
  • Motor - The motor is used to spin the platters from 4,500 to 15,000 rotations per minute (RPM). The faster the RPM of a drive, the better performance you will achieve from it.
When a the computer wants to retrieve data off of the hard drive, the motor will spin up the platters and the arm will move itself to the appropriate position above the platter where the data is stored. The heads on the arm will detect the magnetic bits on the platters and convert them into the appropriate data that can be used by the computer.Actually these magnetic Bits are also refers to as a magnetic domains which gets align themselves according to the binary zeroes and ones. 
Conversely, when data is sent to the drive, the heads will this time, send magnetic pulses at the platters changing the magnetic properties of the platter, and thus storing your information.
It is important to note, that since the data stored on your hard drive is magnetic, that why the people are supposed to warn that don`t take the magnet near the Hard drive because it may affect the magnetic Data Stored on the Hard Drive. 


Hard Drive Interfaces:-



Hard Drive
A hard drive connects to your computer through a specific type of interface. The interface on your hard drive must match the corresponding interface on your motherboard. If you purchase a new hard drive that has a interface which doesn't matches with the interface of the Mother Board Installed on your Computer, then it will not work in your computer. Basically there are three interfaces that have become the standard for connecting your hard to your computer. Some information about each of these interfaces are below.
  • IDE or ATA - This is currently the most common interface used but is quickly becoming overcome by the newer SATA interface. Hard drives using this type of interface have speeds up to 100 Mbps.
  • SATA - A newer interface that uses less bulky cables and has speeds starting at 150 Mbps for SATA and 300 Mbps for SATA II. Almost all computer manufacturers have started using SATA drives.
  • SCSI - This type of interface is typically used in a business environment for servers. Hard Drives designed for a SCSI interface tend to have a faster RPM which therefore provides better performance.
Read More
back to top