C Inter
C Inter
1. Automatic variables
2. External variables
3. Static variables
4. Register variables
7.What is the difference between structures & unions?
1.NULL Pointer
2.Dangling Pointer
3.Generic Pointers
4.Wild Pointer
5.Complex Pointers
6.Near Pointer
7.Far Pointer
8. Huge Pointers
NULL Pointer :Literal meaning of NULL pointer is a pointer which is pointing to
nothing. NULL pointer points the base address of segment. Examples of NULL
pointer
NULL is macro constant which has been defined in the heard file as :
#define NULL 0
Dangling pointer :If any pointer is pointing the memory address of any variable
but after some variable has deleted from that memory location while pointer is
still pointing such memory location. Such pointer is known as dangling pointer
and this problem is known as dangling pointer problem.
We cannot dereference generic pointer. We can find the size of generic pointer
using sizeof operator. Generic pointer can hold any type of pointers like char
pointer, struct pointer, array of pointer etc without any typecasting.
Wild pointer :A pointer in c which has not been initialized is known as wild
pointer.
Complex pointer :
Pointer to function
Pointer to array
Pointer to array of integer
Pointer to array of function
Pointer to array of character
Pointer to array of structure
Pointer to array of union
Pointer to array of array
Pointer to two dimensional array
Pointer to three dimensional array
Pointer to array of string
Pointer to array of pointer to string
Pointer to structure
Pointer to union
Multilevel pointers
In TURBO C there are three types of pointers. TURBO C works under DOS
operating system which is based on 8085 microprocessor.
1. Near pointer: The pointer which can points only 64KB data segment or
segment number 8 is known as near pointer.
2. Far pointer: The pointer which can point or access whole the residence
memory of RAM i.e. which can access all 16 segments is known as far pointer.
3. Huge pointer:The pointer which can point or access whole the residence
memory of RAM i.e. which can access all the 16 segments is known as huge
pointer.
http://www.emblogic.com/blog/12/what-are-the-different-types-of-c-pointers/
Here double is a return type of function, p2f is name of the function pointer
a00000000000000000000nd (double, char) is an argument list of this function.
Which m0eans the first argument of this function is of double type and the
second argument is char type.
https://beginnersbook.com/2014/01/c-function-pointers/
A: #include<stdio.h>
int main(){
int n, s1, s2, z;
printf(" How many Integer numbers : ");
scanf("%d", &n);
z=n;
if(n>0){
printf("\n Enter the First number : ");
scanf("%d", &s1);
n--;
if(n>0){
for(;n>=1; n--){
printf("\n Enter the next number : ");
scanf("%d", &s2);
if(s1<s2)
s1=s2;
}
}
}
printf("\n The Largest of %d numbers is %d", z, s1);
return(0);
}
In C, data are free entities and can be In C++, Encapsulation hides the data
manipulated by outside code. This is to ensure that data structures and
because C does not support information operators are used as intended.
hiding.
C does not support function and operator C++ supports both function and
overloading. operator overloading.
C does not allow functions to be defined In C++, functions can be used inside a
inside structures. structure.
C does not have namespace feature. C++ uses NAMESPACE which avoid
name collisions.
A namespace is a declarative region
that provides a scope to the
identifiers (the names of types,
functions, variables, etc) inside it.
Namespaces are used to organize
code into logical groups and to
prevent name collisions that can occur
especially when your code base
includes multiple libraries. All
identifiers at namespace scope are
visible to one another without
qualification. Identifiers outside the
namespace can access the members
by using the fully qualified name for
each identifier.
C uses functions for input/output. For C++ uses objects for input output. For
example scanf and printf. example cin and cout.
C has no support for virtual and friend C++ supports virtual and friend
functions. functions.
C does not provide direct support for error C++ provides support for exception
handling (also called exception handling) handling. Exceptions are used for
"hard" errors that make the code
incorrect.
5.Syntax of malloc ?
A:1.For integer-int* malloc(n*size of (int))
2.For character-char * malloc(n*sizeof (char)).
//6.Copy the arry1 to arry2 with different indexes ,what is the logic
you will use?(REPEATED)
7.Without using strlen library function ,how will you implement to find
length of string?
A: #include<stdio.h>
int main()
{
Char str[100],i;
printf(“Enter a String: \n”);
scanf(“%s”,str);
for(i=0; str[i]!= ‘\0’ ; ++i);
printf(”\n Length of input string:%d”,i);
return 0;
}
O/P:Enter a String
Embedded
Length of input String: 8
Suppose integer is stored as 4 bytes (For those who are using DOS based
compilers such as C++ 3.0 , integer is 2 bytes) then a variable x with value
0x01234567 will be stored as following.
Eg:
#include <stdio.h>
int main()
{
unsigned inti = 1;
char *c = (char*)&i;
if (*c)
printf("Little endian");
else
printf("Big endian");
getchar();
return 0;
}
O/P: Little endian
Function Syntax
malloc () malloc (number *sizeof(int));
11.inti= 9;
i= !i> 15;
printf(“i= %d”, i);
what is the output?
12. char j[ ] ={ ‘a’ ,’ b’,’c’,’\n’,’ c’,’\0’};
Char *p,*str, *str1;
P= &j[3];
Str = p;
Str1= j;
Printf(“%d”, ++*p+ ++*str1-32);
What is the output?
13. int a[2][2][2] ={{10,2,3,4},{5,6,7,8}};
Int *p, *q ;
P=&a[2][2][2];
*q =***a;
Printf(“ %d ------ %d”, *p,*q);
What s out put?
14. char *p= “hi friends”, *p1;
P1=p;
While(*p!=’\0’)
++*p++;
Printf(“%s %s ”,p,p1);
What is the output?
MBIT
1.Find middle node in a linked list ?
A:In order to find middle element of linked list in one pass, you need to maintain
two pointers, one increment at each node while other increments after two
nodes at a time. By having this arrangement, when first pointer reaches end,
second pointer will point to middle element of linked list.
https://www.geeksforgeeks.org/write-a-c-function-to-print-the-middle-of-the-
linked-list/
https://www.geeksforgeeks.org/merge-sort/
3.Structure padding
struct a
{ int a;
Char b;
Float c;
Short d;
}
Struct a
{
Int *a;
Char *b;
Float *c;
Short *d;
}
Fill the above structure members and print the values in the structure
members?
4.How to avoid structure padding ?
A: https://www.allinterview.com/showanswers/62991/how-to-avoid-
structure-padding-in-c.html
return0;
}
6.How to exit from while loop without using return ,break, continue ?
A:
7.How to extract 5 to 10 bits in a integer ?
A:
PATHPARTNER
1.Write recursive function to write (x%y) using multiple substance.
2.Using 2 arrays write a function to find common element in both A
and B arrays.
3.find the output of the following program
main()
{
intx,y;
x=5=N;
fib( );
printf(“%d”, x);
}
int fib(int n)
{
intNum,
N;
return ;
printf(“%d”,N);
x - -;
fib( );
return ;
}
4.Functions for binary input to convert all numbers to 1 after 1’s bit.
0000 0000 0000 0001 1100
0000 0000 0000 0001 1111
5.Write a program to use space and time complexity for count
multiple integers numbers with out using array.
TECH MAHINDRA
1.Write a program for swap two variables.
2.Write a program for fibnoic series?
3.Difference between structure and unions?
4.What are the storage class or variables and explain?
5.Difference between macro and typedef with examples?
What is function pointer?
7.Is it possible static is variable in another file?why?
8.What is inline function ?(c++).
9.Can we use static for functions or not?
VALEO
1.Explain about volatile keyword?(with example)
2.Difference between static function and non static function?
3.What is bit field with example?
4.What is the use of register keyword?
5.Which is the better loop for infinity loop in c?
6.How raw values are converted into human understandable
values(explain logic)?
7.Write a C program for triangle or pyramid?
8.main( )
{
printf(“%p”,main);
}
What is the output of the program?
9.main( )
{
clrscr( );
}
clrscr( );
what is output?
10.main( )
{
char *p;
p=”hello”;
printf(“%c”,*P);
}
What is the output?
VIZZITECH SOLUTIONS
1.Difference between malloc&callloc?
2.storage classes in C?
3.Difference between long, short,double?
4.Explain Stack and Quees operations?
5.Use of pointers? ++*P increaments?
6.What is sorting?
7.Difference between bubble sorting and quick sorting ?
VOTARY TECH
1.Program for multiplication given by user. Multiplication number and
row no. to be multiplied given by the user
Ex: multiplication number 5, row =20
5*1=5 to 5*20=100;
Multiplication functionality done using functions.
2.Enter the numbers ex:5, the range of no. is stored in an array. Write
a program using functions to print the reverse of given array and main
function program is used only to print reverse numbers.
3.Program to print the prime numbers ,given by the user (10 to 1000),
(50 to 2000)and program using functions.
4.write the decimal output for following.(no need of program)just write
steps.
I) v1=45, v2=036
v1&v2, v1|v2, v1^v2
ii) v1=49, v2= 12;
v1&v2, v1|v2, ~v1, v1>>3, v1<<2
iii) v1= 0xA5 ,v2=AB
v1&v2, v1|v2 , v1^v2, ~v1, ~v2, v1>>3, v1<<2
VOTARY TECH
1.what are the compilation stages in c? what are data types?
2.Difference between structures and unions?
3.What is palindrome ?write all four and five numbers palindram?
4. Linked list in python?
5. Recursion of a string print “hello world ”in python.
6.Diamand pattern with 1’s?
WINIT SOLUTIONS
1.Division of two numbers with division operator?
2.Linked list reverse and node deletion?
3.suduko validation/
4.In an array the absoult sum of two numbers real to zero.
5.Leadeship of numbers in an array/
6.Alternative words reverse?
7.Alternative prime numbers?
8.using single for loop find 3 largest elements in an array/
9.using single for loop compare two arrays having common elements?
10.Rotation of array checking ?
XPETIZE
1.Why we use typecasting?
2.Difference between typecasting and typedef?
3.C compilation steps?
NCR
1.Can you write a program to display prime numbers for range n given
by the user?
2.Write a program for fibnocci series?
3.Write a program for factorial of a given number using recursive
function?
where 25 store?
5.inti=10;
printf("%d%d%d%d",++i,i/2,i,--i/2);
/* HCL interview on 25-02 first round written test second round face to
face */
/*--------------*/
1. n*5;
1=n
2=n-1;
3=n-3;
c=a+++7;
11.how to return multiple values from a function.
using call by reference.
/*winit software*/
1st round
1.Write a program for digital watch.
2.Write a program for decimal number to 1.octal 2.hexadecimal 3.
Binary .
n=4; n=5;
2 1
1 2 3 12
1 2 3 4 1 2 3
1 2 3 1 2 3 4
1 1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
4. Write aprogram for finding no.fo Zeros & ones and display them .
5. Write aprogram for the given numbers in order like asssending and
desending order.
6.Writea program for to create a tree.
/*votary tech*/
//1.malloc,calloc explain it.
2.Write a program for the ATM cash withdraw what logic you used.
A:
3.Reversing a string.
4.Tell me about some sorting technics?