## INDEX

### C interview questions and answers

C interview questions and answers for freshers. It is basic c language technical frequently asked interview questions and answers. It includes data structures, pointers interview questions and answers for experienced
Interview questions and answer of C with explanation for fresher

1
Write a c program to print Hello world without using any semicolon.
Explanation:
Solution: 1
void main(){
if(printf("Hello world")){
}
}

Solution: 2
void main(){
while(!printf("Hello world")){
}
}

Solution: 3
void main(){
switch(printf("Hello world")){
}
}

2
Swap two variables without using third variable.
Explanation:
#include<stdio.h>
int main(){
int a=5,b=10;
//process one
a=b+a;
b=a-b;
a=a-b;
printf("a= %d  b=  %d",a,b);

//process two
a=5;
b=10;
a=a+b-(b=a);
printf("\na= %d  b=  %d",a,b);
//process three
a=5;
b=10;
a=a^b;
b=a^b;
a=b^a;
printf("\na= %d  b=  %d",a,b);

//process four
a=5;
b=10;
a=b-~a-1;
b=a+~b+1;
a=a+~b+1;
printf("\na= %d  b=  %d",a,b);

//process five
a=5,
b=10;
a=b+a,b=a-b,a=a-b;
printf("\na= %d  b=  %d",a,b);
return 0;
}

3
What is dangling pointer in c?
Explanation:
Dangling pointer:

A dangling pointer arises when it continues to reference a memory address that once held a variable but has since been deallocated. This situation is commonly referred to as the dangling pointer problem.

Initially:

Later:
For example:

What will be output of following c program?

#include<stdio.h>

int *call();
int main(){

int *ptr;
ptr=call();

fflush(stdin);
printf("%d",*ptr);
return 0;
}
int * call(){

int x=25;
++x;

return &x;
}

Output: Garbage value

Note: Certain compilers may issue a warning message when returning the address of a local variable or a temporary.

Explanation: The variable 'x' is a local variable, confined to the scope and lifetime of the function call. Consequently, after returning the address of 'x', the variable 'x' becomes invalid, while the pointer 'ptr' persists in pointing to that location.

Solution of this problem:
Make the variable x is as static variable. In other word we can say a pointer whose pointing object has been deleted is called dangling pointer.

#include<stdio.h>

int *call();
int main(){
int *ptr;
ptr=call();

fflush(stdin);
printf("%d",*ptr);
return 0;
}
int * call(){

static int x=25;
++x;

return &x;
}

Output: 26

4
What is wild pointer in c?
Explanation:
An uninitialized pointer in C is commonly referred to as a "wild pointer."
Example:

What will be output of following c program?

int main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
return 0;
}

Garbage value

In this context, 'ptr' is deemed a wild pointer due to its lack of initialization. It's crucial to distinguish between a NULL pointer and a wild pointer. A NULL pointer points to the base address of a segment, serving as a deliberate indication of no specific memory location, whereas a wild pointer lacks such a targeted assignment.

5
What are merits and demerits of array in c?
Explanation:

(a) Facilitates straightforward access to each array element. (b) Reduces the need for an excessive number of variable declarations. (c) Ensures the storage of array elements in contiguous memory locations.

Drawbacks:

(a) Incurs memory wastage, and the array size cannot be altered dynamically during runtime. (b) Restricts the storage capability to a singular data type.

6
Do you know memory representation of int a = 7 ?
Explanation:

Memory Representation:

For `signed int a = 7;` in Turbo C Compiler:

Binary equivalent of data 7 in 16 bits: `00000000 00000111` Data bits: `0000000 00000111` (Take the first 15 bits from the right side)

Sign bit: `0` (Take the leftmost one bit)

The first eight bits of the data bits from the right side, i.e., `00000111`, will be stored in the leftmost byte from right to left side. The remaining seven bits of the data bits, i.e., `0000000`, will be stored in the rightmost byte from right to left side.

For `signed short int a = 7` in both Turbo C and Linux GCC Compiler:

Binary equivalent of data 7 in 16 bits: `00000000 00000111` Data bits: `0000000 00000111` (Take the first 15 bits from the right side)

Sign bit: `0` (Take the leftmost one bit)

The first eight bits of the data bits from the right side, i.e., `00000111`, will be stored in the leftmost byte from right to left side. The remaining seven bits of the data bits, i.e., `0000000`, will be stored in the rightmost byte from right to left side.

7
What is and why array in c?
Explanation:

An array in the C programming language is a composite data type capable of storing elements of the same data type in contiguous memory locations. These elements may include primitive types such as int, char, float, double, as well as more complex types like the address of a union, structure, pointer, function, or another array.

Example of array declaration:

int arr[5];
char arr[5];
float arr[5];
long double arr[5];
char * arr[5];
int (arr[])();
double ** arr[5];

Array is useful when:

(a) Arrays are particularly advantageous when dealing with a substantial volume of data of the same type. In scenarios where numerous variables of a similar kind are involved, it becomes cumbersome to individually name and manage each variable within a program. This challenge can be efficiently addressed by utilizing arrays. Instead of maintaining a lengthy list of variable names, an array provides a compact and organized way to store and process a large set of homogeneous data. This not only simplifies the code-writing process but also enhances program readability and maintainability.

For instance, consider the following scenario without using an array:

int ax=1, b=2, cg=5, dff=7, am=8, raja=0, rani=11, xxx=5, yyy=90, p, q, r, avg; avg = (ax + b + cg + dff + am + raja + rani + xxx + yyy + p + q + r) / 12; printf("%d", avg);

In contrast, the array-based approach significantly improves code conciseness:

int arr[] = {1, 2, 5, 7, 8, 0, 11, 5, 50}; int i, avg = 0; for (int i = 0; i < 12; i++) { avg += arr[i]; } printf("%d", avg / 12);

Utilizing arrays in this manner streamlines code, reduces the likelihood of errors, and enhances the overall efficiency of handling large datasets.

//PROCESS ONE
int main(){
int ax=1;
int b=2;
int cg=5;
int dff=7;
int am=8;
int raja=0;
int rani=11;
int xxx=5;
int yyy=90;
int p;
int q;
int r;
int avg;
avg=(ax+b+cg+dff+am+raja+rani+xxx+yyy+p+q+r)/12;
printf("%d",avg);
return 0;
}
If we will use array then above program can be written as:

//PROCESS TWO
int main(){
int arr[]={1,2,5,7,8,0,11,5,50};
int i,avg;
for(int i=0;i<12;i++){
avg=avg+arr[i];
}
printf("%d",avg/12);
return 0;
}

Question: Write a C program to find out average of 200 integer number using process one and two.

(b) Arrays offer a compelling solution when there is a need to store a considerable amount of data in a contiguous memory location. One of the key advantages of arrays is their inherent ability to ensure that elements are stored sequentially in memory. This contiguous allocation facilitates efficient access to elements through indexing, as memory locations are adjacent. This contrasts with non-array data structures where elements may be scattered in memory, leading to less predictable access patterns.

For instance, when dealing with a large dataset, the use of arrays ensures that the elements are stored consecutively, promoting efficient memory utilization and facilitating faster retrieval. This characteristic becomes especially beneficial when there is a requirement for sequential processing or when direct access to specific elements is crucial. In scenarios where data locality is essential for performance, arrays provide a straightforward and reliable mechanism for achieving continuous memory storage.

What will be output when you will execute the following program?

int main(){
int arr[]={0,10,20,30,40};
char *ptr=arr;
arr=arr+2;
printf("%d",*arr);
return 0;
}

Conciseness and Easy Naming:
Arrays offer a concise way to represent a collection of elements under a single name. This simplifies the code and makes it easier to manage and remember the names of individual elements within the array.

Efficient Element Access:
The array name provides the base address of the array. Utilizing the increment operator, it becomes straightforward to sequentially visit each element of the array. This efficient access to elements is especially beneficial when performing operations or computations on the entire array.

Applications in Data Structures:
Arrays play a fundamental role in various data structures. Their ordered and contiguous nature makes them well-suited for implementations of essential data structures such as stacks, queues, and matrices. This versatility contributes to the effectiveness of arrays in organizing and manipulating data in different computational scenarios.

Array of Pointers in C:

An array of pointers in C is a composite data structure where each element of the array holds the address of another variable. This arrangement is particularly useful when dealing with multiple variables, and the array of pointers acts as a collection of references to these variables. Here's an example for better illustration:

int main(){
float a=0.0f,b=1.0f,c=2.0f;
float * arr[]={&a,&b,&c};
b=a+c;
printf("%f",arr[1]);
return 0;
}

8
Why we use do-while loop in c? Also tell any properties which you know?
Explanation:
This loop, alternatively known as a post-tested loop, is employed when it is essential to ensure the execution of the loop at least once. The syntax is as follows:

do {
Loop body
} while (Expression);

Example:

int main(){
int num,i=0;

do{
printf("To enter press 1\n");
printf("To exit press  2");
scanf("%d",&num);
++i;
switch(num){
case 1:printf("You are welcome\n");break;
default : exit(0);
}
}
while(i<=10);
return 0;
}

Output: 3 3 4 4

If the loop body consists of only one statement, the use of braces becomes optional. For example:

(a)
int main(){
double i=5.5678;
do
printf("hi");
while(!i);
return 0;
}

Output: 3 3 4 4

(b)
int main(){
double i=5.63333;
do
printf("hi");
while(!i);
return 0;
}

Output: hi

(c)
int main(){
int x=25,y=1;
do
if(x>5)
printf(" ONE");
else if(x>10)
printf(" TWO");
else if(x==25)
printf(" THREE");
else
printf(" FOUR");
while(y--);
return 0;
}

Output: ONE ONE

9
What is the meaning of prototype of a function?
Explanation:
Prototype of a function

The declaration of a function is referred to as the prototype of the function. The prototype encompasses the following information:

1. The return type of the function.
2. The parameters that the function accepts.

For instance, the prototype of the `printf` function is as follows:

int printf(const char *, …);

Namely, the return type of `printf` is of integer data type. Its first parameter is a constant character pointer, and the second parameter is specified as an ellipsis, indicating a variable number of arguments.

10
Write a c program to modify the constant variable in c?
Explanation:
Constant variables can be modified through the use of pointers. For instance:

#include<stdio.h>
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
return 0;
}

Output: 20

11
What is pointer to a function?
Explanation:
(1) What will be output if you will execute following code?
int * function();
int main(){
auto int *x;
int *(*ptr)();
ptr=&function;
x=(*ptr)();
printf("%d",*x);
}
int *function(){
static int a=10;
return &a;
}

Output: 10
Explanation: In this context, a 'function' refers to a function with a parameter of void data type and a return type of a pointer to int.
x=(*ptr)()
=> x=(*&functyion)() //ptr=&function
=> x=function() //From rule *&p=p
=> x=&a
So, *x = *&a = a =10

(2) What will be output if you will execute following code?

int find(char);
int(*function())(char);
int main(){
int x;
int(*ptr)(char);
ptr=function();
x=(*ptr)('A');
printf("%d",x);
return 0;
}
int find(char c){
return c;
}
int(*function())(char){
return find;
}

Output: 65
Explanation: In this scenario, the function named 'function' takes a parameter of void data type and returns another function. The returned function, in turn, accepts a parameter of char data type and has a return type of int.

x=(*ptr)(‘A’)
=> x= (*function ()) (‘A’) //ptr=function ()
//&find=function () i.e. return type of function ()
=> x= (* &find) (‘A’)
=> x= find (‘A’) //From rule*&p=p
=> x= 65

(3) What will be output if you will execute following code?

char * call(int *,float *);
int main(){
char *string;
int a=2;
float b=2.0l;
char *(*ptr)(int*,float *);
ptr=&call;
string=(*ptr)(&a,&b);
printf("%s",string);
return 0;
}
char *call(int *i,float *j){
static char *str="c-pointer.blogspot.com";
str=str+*i+(int)(*j);
return str;
}

Output: inter.blogspot.com
Explanation: The function named 'call' has a return type of a pointer to character. It takes two parameters: one is a pointer to int data type, and the other is a pointer to float data type. The pointer 'ptr' is declared to point to this function.

str= str+*i+ (int) (*j)
=”c-pointer.blogspot.com” + *&a+ (int) (*&b)
//i=&a, j=&b
=”c-pointer.blogspot.com” + a+ (int) (b)
=”c-pointer.blogspot.com” +2 + (int) (2.0)
=”c-pointer.blogspot.com” +4
=”inter.blogspot.com”

(4) What will be output if you will execute following code?

char far * display(char far*);
int main(){
char far* string="cquestionbank.blogspot.com";
char far *(*ptr)(char far *);
ptr=&display;
string=(*ptr)(string);
printf("%s",string);
}
char far *display(char far * str){
char far * temp=str;
temp=temp+13;
*temp='\0';
return str;
}

Output: cquestionbak
Explanation: The function 'display' is defined with a parameter of a pointer to character and a return type of a pointer to character. The pointer 'ptr' is assigned to point to this function.

temp is char pointer
temp=temp+13
temp=’\0’

In the given context, the two lines entail the replacement of the first dot character in the string variable 'cquestionbank\0blogspot.com' with a null character. It's worth noting that the '%s' format specifier is employed to print characters from the stream up to the null character in a string.

12
Write a c program to find size of structure without using sizeof operator?
Explanation:
struct  ABC{
int a;
float b;
char c;
};
int main(){
struct ABC *ptr=(struct ABC *)0;
ptr++;
printf("Size of structure is: %d",*ptr);
return 0;
}

13
What is NULL pointer?
Explanation:
The literal meaning of a NULL pointer is a pointer that points to nothing, signifying the absence of a valid memory location. In practice, a NULL pointer typically points to the base address of a segment. Examples of NULL pointers include:

1. int *ptr=(char *)0;
2. float *ptr=(float *)0;
3. char *ptr=(char *)0;
4. double *ptr=(double *)0;
5. char *ptr=’\0’;
6. int *ptr=NULL;

What is meaning of NULL?

`NULL` is a macro constant defined in header files such as `stdio.h`, `alloc.h`, `mem.h`, `stddef.h`, and `stdlib.h`. It is commonly employed to represent a null pointer, indicating that the pointer does not point to any valid memory location.

#define NULL 0

Examples:

(1)What will be output of following c program?

#include "stdio.h"
int main(){
if(!NULL)
printf("I know preprocessor");
else
printf("I don't know preprocessor");
}

Output: I know preprocessor

Explanation:
In logical terms, the expression `!NULL = !0 = 1` asserts that the negation of a null condition or zero evaluates to true, represented by the value 1. In an 'if' condition, any non-zero number is considered true.

(2)What will be output of following c program?

#include "stdio.h"
int main(){
int i;
static int count;
for(i=NULL;i<=5;){
count++;
i+=2;
}
printf("%d",count);
}

Output: 3

(3)What will be output of following c program?

#include "stdio.h"
int main(){
#ifndef NULL
#define NULL 5
#endif
printf("%d",NULL+sizeof(NULL));
}

Output: 2
Explanation:
NULL + sizeof(NULL)
=0 + sizeoof(0)
=0+2 //size of int data type is two byte.

Copying is not permissible with a NULL pointer, as it denotes the absence of a valid memory location and attempting to copy data to or from it can lead to undefined behavior.

Example:

(4)What will be output of following c program?

#include "string.h"
int main(){
char *str=NULL;
strcpy(str,"c-pointer.blogspot.com");
printf("%s",str);
return 0;
}

Output: (null)

14
What is difference between pass by value and pass by reference?
Explanation:

In C, parameters can be passed to a function using two distinct methods.

(a) Pass by value: In this approach, a copy of the actual variables is passed to the function as parameters. Consequently, any modifications made to these parameters within the function do not affect the original variables. For example:

#include<stdio.h>
int main(){
int a=5,b=10;
swap(a,b);
printf("%d      %d",a,b);
return 0;
void swap(int a,int b){
int temp;
temp =a;
a=b;
b=temp;
}
Output: 5    10

(b) Pass by reference: In this approach, we pass the memory address of the actual variables to the function as parameters. Consequently, any modifications made to these parameters within the function directly impact the original variables. For example:
#incude<stdio.h>
int main(){
int a=5,b=10;
swap(&a,&b);
printf("%d %d",a,b);
return 0;
void swap(int *a,int *b){
int  *temp;
*temp =*a;
*a=*b;
*b=*temp;
}

Output: 10 5

15
What is size of void pointer?
Explanation:
The size of any type of pointer in C is independent of the data type it points to. Regardless of whether it's a char pointer, double pointer, function pointer, or null pointer, the size of all near pointers in C is two bytes. This rule extends to void pointers as well; their size is also two bytes.

16
What is difference between uninitialized pointer and null pointer?
Explanation:
An uninitialized pointer is a pointer that points to an unknown memory location, whereas a null pointer is a pointer that points to a null value or the base address of a segment. For example:

int *p;   //Uninitialized pointer
int *q= (int *)0;  //Null pointer
#include<stdio.h>
int *r=NULL;   //Null pointer

What will be output of following c program?

#include<string.h>
#include<stdio.h>
int main(){
char *p;  //Uninitialized pointer
char *q=NULL;   //Null pointer;
strcpy(p,"cquestionbank");
strcpy(q,"cquestionbank");

printf("%s  %s",p,q);
return 0;
}

Output: cquestionbank (null)

17
Can you read complex pointer declaration?
Explanation:
Rule 1: Assign priority to the pointer declaration by considering precedence and associativity according to the following table.

(): This operator functions as a bracket or function operator.

[]: This operator acts as the array subscription operator.

*This operator functions as the pointer operator, distinct from its use as a multiplication operator.

Identifier: Although not classified as an operator, it represents the name of the pointer variable. Priority is consistently assigned to the name of the pointer.

Data type: Similarly not categorized as an operator, data types encompass modifiers (e.g., signed int, long double, etc.).

Understanding these concepts is better illustrated through examples:

(1) How to read following pointer?

char (* ptr)[3]

Step 1: The operators () and [] share equal precedence. As per the rule of associativity (left to right), the first priority is assigned to ().

Step 2: Within the brackets, * and ptr have equal precedence. According to the right-to-left rule of associativity, the first priority is assigned to ptr, and the second priority goes to *.

Step 3: Assign the third priority to [].

Step 4: As the data type has the least priority, assign the fourth priority to char.

Now, read it in the following manner:

"ptr is a pointer to a one-dimensional array of size three, which contains char-type data."

(2) How to read following pointer?

float (* ptr)(int)

Assign the priority by considering precedence and associativity.

Now, read it in the following manner:

'ptr is a pointer to a function whose parameter is of int type and return type is of float type.'

Rule 2: Assign the priority of each function parameter separately, and read each one separately. Understand it through the following example.

(3) How to read following pointer?

void (*ptr)(int (*)[2],int (*) void))

Assign the priority considering the rule of precedence and associativity.

ptr is pointer to such function which first parameter is pointer to one dimensional array of size two which contentint type data and second parameter is pointer to such function which parameter is void and return type is int data type and return type is void

(4) How to read following pointer?

int ( * ( * ptr ) [ 5 ] ) ( )

Assign the priority considering the rule of precedence and associativity.

Now read it in the following manner:

"ptr is a pointer to an array of size five, where the contents are pointers to functions with a parameter of void type and a return type of int."

(5) How to read following pointer?

double*(*(*ptr)(int))(double **,char c)

Assign the priority considering the rule of precedence and associativity.

Now read it in the following manner:

ptr is a pointer to a function with a parameter of int type and a return type of a pointer to a function. The function it points to has the first parameter as a pointer to a pointer of double data type, the second parameter as a char type data, and the return type as a pointer to double data type.

(6) How to read following pointer?

unsigned **(*(*ptr)[8](char const *, ...)

Assign the priority considering the rule of precedence and associativity.

Now read it in the following manner:

"ptr is a pointer to an array of size eight, where the contents of the array are pointers to functions. The functions have the first parameter as a pointer to a constant character, the second parameter as a variable number of arguments, and the return type as a pointer to a pointer of unsigned int data type."

18
What are the parameter passing conventions in c?
Explanation:
1. 1. Pascal: In this style, the function name (not necessarily) is in uppercase. Parameters in the function call are passed to the corresponding parameters in the function definition, maintaining the order.

2. 2. Cdecl: In this style, the function name can be in both uppercase or lowercase. The first parameter of the function call is passed to the last parameter of the function definition. It is the default parameter passing convention.

Examples could be provided for each style to illustrate their usage.

1. What will be output of following program?

int main(){
static int a=25;
void cdecl conv1() ;
void pascal conv2();
conv1(a);
conv2(a);
return 0;;
}
void cdecl conv1(int a,int b)
{
printf("%d %d",a,b);
}
void pascal conv2(int a,int b)
{
printf("\n%d %d",a,b);
}

Output: 25 0
0 25

(2) What will be output of following program?

void cdecl fun1(int,int);
void pascal fun2(int,int);
int main(){
int a=5,b=5;

fun1(a,++a);
fun2(b,++b);
return 0;
}
void cdecl fun1(int p,int q){
printf("cdecl:  %d %d \n",p,q);
}
void pascal fun2(int p,int q){
printf("pascal: %d %d",p,q);
}

Output:
cdecl:  6 6
pascal: 5 6

(3) What will be output of following program?

void cdecl fun1(int,int);
void pascal fun2(int,int);
int main(){
int a=5,b=5;

fun1(a,++a);
fun2(b,++b);
return 0;
}
void cdecl fun1(int p,int q){
printf("cdecl:  %d %d \n",p,q);
}
void pascal fun2(int p,int q){
printf("pascal: %d %d",p,q);
}

Output:
cdecl:  6 6
pascal: 5 6

(4) What will be output of following program?

void convention(int,int,int);
int main(){
int a=5;

convention(a,++a,a++);
return 0;
}
void  convention(int p,int q,int r){
printf("%d %d %d",p,q,r);
}

Output: 7 7 5
(5) What will be output of following program?

void pascal convention(int,int,int);
int main(){
int a=5;

convention(a,++a,a++);
return 0;}
void pascal  convention(int p,int q,int r){
printf("%d %d %d",p,q,r);
}

Output: 5 6 6

(6) What will be output of following program?

void pascal convention(int,int);
int main(){
int a=1;

convention(a,++a);
return 0;
}
void pascal  convention(int a,int b){
printf("%d %d",a,b);
}

Output: 1 2

(7) What will be output of following program?

void convention(int,int);
int main(){
int a=1;

convention(a,++a);
return 0;}
void  convention(int a,int b){
printf("%d %d",a,b);
}

Output: 2 2

19
What is the far pointer in c?
Explanation:
A far pointer is a type of pointer in a computer program that can access or point to the entire addressable memory of RAM. Specifically, it can access all 16 segments of the memory.

The size of a far pointer is 4 bytes or 32 bits. Examples:

(1) What will be output of following c program?

int main(){
int x=10;
int far *ptr;
ptr=&x;
printf("%d",sizeof ptr);
return 0;
}

Output: 4

(2)What will be output of following c program?

int main(){
int far *near*ptr;
printf("%d %d",sizeof(ptr) ,sizeof(*ptr));
return 0;
}

Output: 4 2
Explanation: `ptr` is a far pointer, whereas `*ptr` is a near pointer.

(3)What will be output of following c program?

int main(){
int far *p,far *q;
printf("%d %d",sizeof(p) ,sizeof(q));
}

Output: 4 4

The first 16 bits store the segment number, while the next 16 bits store the offset address.

Example:

int main(){
int x=100;
int far *ptr;
ptr=&x;
printf("%Fp",ptr);
return 0;
}

Output: 8FD8:FFF4

In the given context, '8FD8' represents the segment address, and 'FFF4' represents the offset address in hexadecimal number format.

Note: `%Fp` is used to print the offset and segment address of a pointer in the `printf` function in hexadecimal number format.

The header file 'dos.h' provides three macro functions for working with far pointers:

1. `1.FP_OFF()`: Used to obtain the offset address from a far address.
2. `2.FP_SEG()`: Used to obtain the segment address from a far address.
3. `3.MK_FP()`: Used to create a far address from segment and offset addresses.

Examples:
(1)What will be output of following c program?

#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
printf("%X %X",FP_SEG(ptr),FP_OFF(ptr));
}

(2)What will be output of following c program?

#include "dos.h"
int main(){
int i=25;
int far*ptr=&i;
unsigned int s,o;
s=FP_SEG(ptr);
o=FP_OFF(ptr);
printf("%Fp",MK_FP(s,o));
return 0;
}

Output: 8FD9:FFF4 (Assume)

Note: The offset address, segment address, and far address of any far pointer are determined by the operating system and cannot be predicted.

Limitation of far pointer:

It is not possible to change or modify the segment address of a given far address by applying any arithmetic operation on it. In other words, using arithmetic operators, we cannot jump from one segment to another. If the far address is incremented beyond the maximum value of its offset address, instead of incrementing the segment address, it will repeat its offset address in a cyclic order.

Example:

(q)What will be output of following c program?

int main(){
int i;
char far *ptr=(char *)0xB800FFFA;
for(i=0;i<=10;i++){
printf("%Fp \n",ptr);
ptr++;
}
return 0;
}

Output:

B800:FFFA
B800:FFFB
B800:FFFC
B800:FFFD
B800:FFFE
B800:FFFF
B800:0000
B800:0001
B800:0002
B800:0003
B800:0004

This property of a far pointer, wherein it exhibits a cyclic nature within the same segment, is referred to as the cyclic nature of far pointers within the same segment.

1. Far pointers compare both offset address and segment address using relational operators

Examples:

(1)What will be output of following c program?

int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
if(p==q)
printf("Both pointers are equal");
else
printf("Both pointers are not equal");
return 0;
}

Output: Both pointers are not equal

(2)What will be output of following c program?

int main(){
int far *p=(int *)0X70230000;
int far *q=(int *)0XB0210000;
int near *x,near*y;
x=(int near *)p;
y=(int near *)q;
if(x==y)
printf("Both pointer are equal");
else
printf("Both pointer are not equal");
return 0;
}

Output: Both pointers are equal

2. Far pointer doesn’t normalize.

20
What is a cyclic property of data type in c? Explain with any example.
Explanation:
#include<stdio.h>
int main(){
signed char c1=130;
signed char c2=-130;
printf("%d  %d",c1,c2);
return 0;
}

Output: -126   126 (why?)
This situation is known as overflow of a signed char. The range of an unsigned char is -128 to 127. If a value greater than 127 is assigned, the variable's value will wrap around to a new value by moving in the clockwise direction, as depicted in the figure according to the number line. Similarly, assigning a number less than -128 requires moving in the anti-clockwise direction.

Data types Interview questions
TCS placement question

Anonymous said...

great job!!

vichy said...

Making a C program, to record the subjects taken by a student, the subjects removed, the approved and disapproved and calculate the GPA for that semester.

The program should have the option of "going out"

Anonymous said...

Superb collection..thanks !!
just one bug to notify in Q.14..printf("Size of structure is: %d",*ptr); *ptr should be changed to ptr

Anonymous said...

Question 14 is correct one. No bug. It will work only Turbo c3.0

Anonymous said...

woov very good post.. thanks a lot to author...

Anonymous said...

superr collectionnnnnnn.............

Anonymous said...

great job what a super collectionnnnnnnnnnnn

Anonymous said...

i want a c program that will display this output:
A B C D E F G F E D C B A
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A

Anonymous said...

Wonderful site.The effort of the site-creator is commendable.Keep it up.Your info. was quite useful.

Anonymous said...

great post!!

Anonymous said...

#include

void main()
{

int no_of_lines, alphabet = 65, i, count, j;

printf("\nenter the number of lines you want to print\t:");
scanf("%d",&no_of_lines);
count=2*no_of_lines;
for(j=0;j<no_of_lines;j++)
{
if(j==0)
{
printf("\n\n");
for(i=0;i<count;i++)
{
if(i<no_of_lines)
{
printf(" %c", alphabet++);
}
else if(i == no_of_lines)
{
alphabet--;
}
else
{
printf(" %c",--alphabet);
}
}
}
else
{
printf("\n");
//printf("\nnothing\n");
for(i=0;i<count-2*j;i++)
{
if(i<no_of_lines-j)
{
printf(" %c", alphabet++);
}
else
{
printf(" %c",--alphabet);
}
}

}
}
}

SAMPLE OUTPUT:

enter the number of lines you want to print : 5

A B C D E D C B A
A B C D D C B A
A B C C B A
A B B A
A A

if u want dat particular format enter the number of lines as 7....

Anonymous said...

Great work ..Lots of hard work ...thanks a lot..becz it helps me a lot

Anonymous said...

main()
{
float a=0.7;
if(a<0.7)
printf("c");
else
printf("c++");
}

output:c

Can anybody explain this plz

Priyanka kumari said...

Hi Anil,

Check the question(4) of following link

Raghu said...

main()
{
float a=0.7;
if(a<0.7)
printf("c");
else
printf("c++");
}

Exp:
in the above program the compiler take it('a') as 0.7000001,so a<0.7 i.e true.so ,it's o/p is "c".

Anonymous said...

its not enough to learn "c" need some more, this is very nice collection,thank full to you

Anonymous said...

void main()
{
int i;
char j;
for(i=71;i>=65;i--)
{
for(j=65;j<=i;j++)
{
printf("%c",j);
}
printf("\n");
}

output:-
ABCDEFG
ABCDEF
ABCDE
ABCD
ABC
AB
A

Anonymous said...

void main()
{
int i;
char j,k;
for(i=71;i>=65;i--)
{
for(j=65;j<=i;j++)
{
printf("%c",j);
}
for(k=i;k>=65;k--)
{
printf("%c",k);
}
printf("\n");
}

output:-
ABCDEFGFEDCBA
ABCDEFFEDCBA
ABCDEEDCBA
ABCDDCBA
ABCCBA
ABBA
AAA

Garden sheds said...

C is a very interesting language and this is a basic of all language, if we have no knowledge of c then we cant understand c++, this is a 1st stage of all programing language.

java tutorial said...

Great! this post is very help for me.

Anonymous said...

Great work...really worthable one

Anonymous said...

awesum collection...

Anonymous said...

Awesome awesome awesome awesome awesome.......

Anonymous said...

Anonymous said...

awesome awesome awesome awesome awesome awesome awesome awesome awesome awesome awesome xcllnt work..............:))))))

Anonymous said...

great post

Anonymous said...

good but need little more

all questions are very easy questions pls post difficult question and their answers

Anonymous said...

good

Unknown said...

Thanks u vary much to create such super blog

Anonymous said...

thank you sooooooooooooooooooooooo much...i find these questions so very useful...i could now confidently face my placement interviews..thanks once again..

Anonymous said...

I need answer for this question immediately before 3 hrs .. pls help me

1.write a c program to divide the no. 73897869by 256 without using +,-,/,* and loop statement??

Anonymous said...

and this too!

write 2 main () independent functions without using comments in a single program..pls help me friends i need the answer the answer immediately

Tanmay Chakrabarty said...

Wow....thats great. I have my Class Notes on C Programming. I shared them in my blog

Tanmay On Run

anurag_dake said...

1)void main()
{
float a=2.1;
if(a==2.1)
printf("TE");
else
printf("BE");
getch();
}
------------------------------------------------------
Whats the OUTPUT of Following Program
2)void main()
{
float a=2.0;
if(a==2.0)
printf("TE");
else
printf("BE");
getch();
}
give Ans with reason....:)

Priyanka kumari said...

Hi Anurag,

Anonymous said...

thanks a lot sir..........

RAJARAJAN said...

super..................site,&&&&&&&&&&&&&&&
super collection.

Anonymous said...

Anonymous said...

excellent work

Anonymous said...

thanks............
supper.....D:)

Anonymous said...

i didnt even expect this much of material ..thanq :) i think it definitly helps me alot..:)

ali.... said...

In the program for dangling pointer if ptr=call()
is written before clrscr() then it prints garbage value ...if written after it prints 26 correctly......Plz explain this..........using turbo C

SANDEEP PANWAR said...

good very good

Anonymous said...

Write a program for a GENERAL NUMBER CONVERTERS which include
binary, decimal, octa and hexadecimal. You need to write the program using C
language.

Priyanka kumari said...

Hi,
http://cquestionbank.blogspot.com/2010/07/c-program-examples.html

Check Conversion ( Number System ) section

Aarav koshik said...

well frnd i have a question---

why the constructor in c++ can't be virtual but destructor can be?

Anonymous said...

I really appreciate this. I shall donate some to this site.

Priyank Gupta said...

This is very use full for students....

Anonymous said...

really good collection.....very useful

Anonymous said...

Anyone plz peast link to find turbo C for windows-7.
i have turboC.exe setup but not working properlly.

Count the total words in a sentence,count once if word repeatting without using lib function.

eg- my name is jawed,my pet name is dog.

Anonymous said...

all genius....
great work...

raviteja said...

void main()
{
float a=2.1;
if(a==2.1)
printf("TE");
else
printf("BE");
getch();
}

In the above program a is float value but 2.1 value directly substituted in program taht value take double datatype.
-- float takes after dot(.) 8 zero's.
-- Double takes after dot(.) 16 zero's.
so.....float is not equal to double.

ans is BE.

Anonymous said...

write a program to find the rank of the number in the one dimensional array without using sorting and using two arrays

Anonymous said...

c++ has any site like c

nice job i didn't see this type of stuff .Why don't you make website, we will made website with low price consult us sankar00002009@gmail.com

Anonymous said...

yes. good

Anonymous said...

thanks

Narottam Singh said...

// This program is written in JAVA language .Which language u r using u can change

public class BB5
{
public static void main(String aa[])
{
int n=20;
int a=1;
int b=n/2;
int c=65+b;
for(int k=1;k<=(n/2+1);k++)
{
for(int i=65;i<=c;i++)
{
System.out.printf("%c",i);

}

for(int j=65+b;j>=65;j--)
{
System.out.printf("%c",j);

}
c--;
b--;
System.out.println();
}
}
}

sudhir rajput said...

#include
#include
void main()
{
int i,j;
clrscr();
for(i=9;i>=1;i++)
{
for(j=i-1;j<=i;j--)
{
printf("%d",j);
}
printf("\n");
}
getch();
}

Cbse exam said...

I Think of your talents as the things you’re really good at. They’re like personality traits. For instance, you may be a very creative person, or a person who’s really good at attending to details or a person with a gift for communicating. Your talents are the base for any successful business venture, including a home-based business.

ನಾಗರಾಜ್ .ಕೆ (NRK) said...

Excellent work . . .thank u

Anonymous said...

wonderful info abt C

Anonymous said...

information is very good

Anonymous said...

great job, really wonderful info.

Anonymous said...

yup the (0.7) in the if statement is by default double type
and float is always less as to double!!
so,float a=0.7 is always less than (0.7 which has it's default datatype double)!!

:-)

Unknown said...

really very useful..thnks a lot

Anshul Jain said...

This is really an awesome blog!!!
Way to go!!!

Unknown said...

Awesome! Awesome ! Awesome!

Thanks a lot. this helps a lot for fast revision of C.

Shubhabrata Naha said...

*hi can u suggest me a good ebook for Recursion in C??
I cant understand recursion :(
plz help me out...

Priyanka kumari said...

How to write function recursion program in easier way

Anonymous said...

it's is very useful..............

Anonymous said...

can u write a code of this output:
Enter a number:12345
:23451
:34512
:45123
:51234
The highest number:51234

Anonymous said...

and this..
Enter a length of line:5
Enter P1:maria
Enter P1:greg
Enter P1:juan
Enter P1:bitoy
Enter P1:melai
SAVE:4

Anonymous said...

i need a program for this

1
2 3
4 5 6
7 8 9 10

Anonymous said...

#include
#include
void main()
{
printf("1
2 3
4 5 6
7 8 9 10");
getch();
}

Anonymous said...

without loops.......use \t for tabs

void main()
{
printf("1\n2 3\n4 5 6\n7 8 9 10");

}

Anonymous said...

hii frnds, i am starting to learn C programming language ....but it seems so difficult, i m studying "LET US C".It is very tuff to understand the concept of looping & Decision making questions...so frnds please me guideline how can i improve my learning....coz i want to make my carier in programming.

Anonymous said...

1.Diff. btw c and c++,
2.Diff btw c++,C,java.
3.what is deceleration and definition.

venki said...

Thank's for providing valuable information,it help's to me............

Anonymous said...

good site .create site gives information for c++,java,DBMS,unix

Anonymous said...

Unknown said...

Kudos to the Blogger!

Anonymous said...

#include

int main (){
unsigned int j;
unsigned char i;
for(j=0;j<7;j++){
for(i = 'a';i <= ('g' - j);i++)
printf("%c", i);

for(i = ('g' - j);i >= 'a';i--)
printf("%c", i);

printf("\r\n");
}
return ;
}

Anonymous said...

hey have you done programming using calloc and malloc?
I am not able to find out...plz tell me where it is?

hitesh kumar said...

above is right

hitesh kumar said...

void main()
{
int j,i,k;
k=1;
for(i=1;i<=4;i++)
{
for(j=i;j<=i;j++)
{
printf("%d",k);
k++;
}
printf("/n");
}
}

hitesh kumar said...

In the above program a is float value and 0.7 value directly substituted in program that value take double datatype.
-- float takes after dot(.) 8 zero's.
-- Double takes after dot(.) 16 zero's.
so.....float is always less than double.
Output of this program is C

Anonymous said...

They are useful everyone for developing career...

good work keep it up...

Anonymous said...

what is the output for following query:
1.select greatest(94,'845','846') from dual;
2.select greatest('94','845',846) from dual; can anyone explain me plz

rakesh said...

// this is correct , just check it , run it

#include "stdio.h"

int main()
{
int j,i,k;
k=1;
for(i=1;i<=4;i++)
{
for(j=0;j<i;j++)
{
printf("%d ",k);
k++;
}
printf("\n");
}
return 0;
}

Unknown said...

how to write a c program to find birth year by NIC number

Unknown said...

hi frds i need ur help can anybody tell me the program for this algorithm??plz send to my mail id sasiviji95@gmail.com as soon as possible plz frds it's my request,,
write a c++ program to print the following triangle
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
algorithm:
s1:start the program
s2:
declare i,jand n as int data type
s4:fori=n to greater then or equal to 0
s4.1:for j=i to less than n print y
s5: stop the program
output:
enter number of lines 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Unknown said...

thanks a lot

Anonymous said...

#include
#include

char *
rotate(char *str)
{
char *cp = str;
char ch = *cp++;
int i;

while (*cp) {
*(cp-1) = *cp++;
}
*(cp-1) = ch;

return str;
}

void
shuffle(char *str)
{
long bigval = 0;
int i;
long val = 0;

printf("Shuffling...\n");

for (i=0; i < strlen(str); i++) {
printf("%s\n", str = rotate(str));
val = atol(str);
if (!bigval || val > bigval ) {
bigval = val;
}
}

printf("Biggest shuffle is %d\n", bigval);

}

main()
{
char buf[64];
printf("\nEnter +ve number : ");
scanf("%s",&buf);
shuffle(buf);
}

Unknown said...

best site i ever user..

Anonymous said...

plz type the program this output display in c lang

kairam said...

your blog is soo use full and ur c skills are awesm :)

reallyoldturlte said...

Pass by reference is NOT possible in C.

The program will work however its not an example of "pass by reference"

NAVAL said...

IN the 10th question........where is const variable???

Anonymous said...

int main(){
float a=0.0f,b=1.0f,c=2.0f;
float * arr[]={&a,&b,&c}; // ************
b=a+c;
printf("%f",arr[1]);
return 0;
}

hy this is producing an error :Illegal Initialization I have marked that line by ******.......
Plz help

Abhishek Alwani said...

What is difference between dequeue and deque?

Unknown said...

/*This program written in C Language*/
#include
main()
{
char i,j,k;
for(i='G';i>='A';i--)
{
for(j='A';j<=i;j++)
{
printf("%c",j);
}
for(k=i;k>='A';k--)
{
printf("%c",k);
}
printf("\n");
}
}

chahal said...

Please make a program to reverse the string "MY NAME IS KHAN" to "KHAN IS MY NAME".

Anonymous said...

what is memory representation of 5.235!!!!!!

Anonymous said...

PRASANNA said...

good good,thanxxxxxxxxxxxxxxx

RAJAT SAPRA said...

the way you explain in q17 is awesome I hve ever read.. :)

Anonymous said...

#include
int main()
{
int a,n=7,i,c;
for(i=0;i<=n;i++)
{for(c=0;c<=(n-i);c++)
printf(" ");
for(c=0,a=65;c<=i;c++,a++)
printf("%c",a);
printf("\n");
}
n++;
for(i=n;i<=16;i++)
{
for(c=0;c<=n-i;c++)
printf(" ");
for(c=0,a=65;c<=(2*n-i);c++,a++)
printf("%c",a);

printf("\n");
}
return 0;
}
out put is :
A
A B
A B C
A B C D
A B C D E
A B C D
A B C
A B
A

Unknown said...

void main()
{
int i=30;
int j=40;
printf("%d..%d");
getch();
}
output- 40..30
plz tell m logic used in this prog.

Anonymous said...

yeah man this is it all you need good work

Sai Manohar Boidpap said...

awesome !! great explanation !!!!! very thanq sir :)

Unknown said...

your blog is soo use full and ur c skills are awesm :)

Anonymous said...

hello frnds
any logic bits are there
plz tell me
help me

Anonymous said...

write a program in c input 1 and the output 100 anybody rly me pls

Anonymous said...

setup an internet connection and share this connection using proxy server with limited service that is only HTTP and FTP? please friends answer the quetion............

Anonymous said...

Write a "C" programe to show weekday when input 1 show Monday 2 tuesday as show on using the switch statement? give me answer the que..........

Anonymous said...

What is the output of the following code segment?
int i=1;
do
while(i++<=5);
while(i++<=4);
while(i++<=3);
printf(“%d”,i);

Anonymous said...

What is the output of the following code segment?
int i=1;
while(i++<5);
printf("%d",i);

Jobs said...

superb...................

Pramesh Pudasaini said...

Thank you! Good questions.

Unknown said...

#include
#include
#include
void arraydivide(char a[])
{
int i,j,k,l,length;
length=strlen(a);
for(i=length-1;i>=0;i--)
{
for(j=0;j<=i;j++)
{
printf("%c",a[j]);
}
if(i==length-1)
for(k=i-1;k>=0;k--)
{
printf("%c",a[k]);
}
else
{
for(l=i;l>=0;l--)
{
printf("%c",a[l]);
}
}
printf("\n");
}
}
void main()
{
char a[]={"ABCDEFG"};
clrscr();
arraydivide(a);
getch();
}

Unknown said...

can u pls help me to get output in dis format and also explain them
#
# # #
# # # # #
# # # # # # #

Anonymous said...

#include /* it's in c language*/

int main()
{

int lines,i,j;

scanf("%d",&lines); /** the number of lines that you need*/
for(i=0; i<lines; i++)
{
printf("#");

for(j=0; j<i; j++)
printf("##");

printf("\n");

}

return 0;
}

Avi said...

Its written in c...

#include
#include
int main(){
char ch,comp;
comp='G';
int i;
for(i=0;i<7;i++){
ch=65;
while(ch<=comp){
printf("%2c",ch++);
}
if(ch=='H'){
ch=ch-2;
}
else{
ch--;
}
while(ch>=65){
printf("%2c",ch--);
}
comp--;
printf("\n");}

getch();
return(0);
}

Unknown said...

too good site

Unknown said...

Array of pointers in c:

Array whose content is address of another variable is known as array pointers. For example:

int main(){
float a=0.0f,b=1.0f,c=2.0f;
float * arr[]={&a,&b,&c};
b=a+c;
printf("%f",arr[1]); not this // here Printf("%f",*arr[1]); this is true sentence
return 0;
}

Unknown said...

10)
Write a c program to modify the constant variable in c?
Explanation:
You can modify constant variable with the help of pointers. For example:

#include
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
return 0;
}

Output: 20

MISTAKE :: *ptr=(int)20;

Unknown said...

Unknown said...

mistake :: Q--12 A--12
printf("Size of structure is: %d",*ptr); //this st. provide address of the value not actual value

true statement is :: printf("Size of stucture is: %d",ptr); // this st. provide actual value

Unknown said...

printf("%f",*arr[1]);

Unknown said...

constant variable means not const it's just member variable which hold some specific value.
and u thing the const, we cant change its value accept help of hardware time.

Unknown said...

u can use pointer of multiple array. using this feature u can build your program what u want.

Unknown said...

how we can print N*N matrix without using an array

Unknown said...

int main()
{
int a=15;
a=(++a)+015+0x15;
printf("%d",a);
return 1;
}

i don't know how to work octal and hex hear so plz tell me what is o/p with explanation of that prog.

Unknown said...

if u can u get all the answer for above question ill be very thankfull for the one

Unknown said...

Q) Write a program to identify keyword in 'c'
sample input: for

sample output: this is keyword

sample input: why

sample output: this is not keyword

Unknown said...

guys code for
Input: 12/02/1993
Output: 12-feb-1993

Unknown said...

int i,j;
for(i=5;i>0;i--)
{
for(j=0;j<=(5-i);j++)
{
printf("%d",j+i);
}
printf("\n");
}

Unknown said...

thank you... such a nice collection. keep it up..

manu said...

c program for merging two arrays into a single array alternatively:
sample Input:
a[]=1,2,3,4
b[]=a,b,c,d
sample output:
1,a,2,b,3,c,4,d

Unknown said...

1
12
123
1234

Unknown said...

it was good material to the freshers

Unknown said...

it prints 1

Anonymous said...

plz solve this problem through while and for loop
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

Anonymous said...

plz help me

Anonymous said...

plz help me

Unknown said...

write a programm to draw w shap by using height=5,width=2 in c or java

\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \
\ \ \ \ \ \ \ \

Unknown said...

sorry above shape is not correct. print w shape

Unknown said...

i want a c program to
print the following pattern
1 2 4 7
2 5 8 11
6 9 12 14
10 13 15 16

Unknown said...

i want a c program to
Find whether the given word can be converted into palindrome or not
Ex : 1
Input : tests
It can be converted into tsest or stets
Output : Yes
Ex : 2
Input : arm
Output : No

Unknown said...

*
* *
* * *
* * * *
* * *
* *
*

Unknown said...

i want a this output's program

Unknown said...

thanks a lot

Unknown said...

i need program for following
a
as
asp
aspi
aspir
aspire

Anonymous said...

I want to know the answer
C programming Using nested loop
Input n=3
output:
S1: 1!+2!+3!+........+n!=9
S2: 1!+3!+5!+........+(2n-1)!=127
S3: 2!+4!+6!+........+2n!=736

Anonymous said...

How can i understand patterns in c programming......
*
**
***
****

tiger said...

Create a program to calculate the salary and bonus based on sales of a staff.

(i) In main() :

(ii) In function get_bonus(...) :

- Ask the user to enter satff id, salary and units sold.

- Call function get_bonus(...) and pass units sold and salary to calculate

the bonus amount.

- Call function get_nett_salary(...) and pass salary and bonus amount to

calculate the nett salary.

- Call function display(...) and pass staff id, salary, units sold, bonus

amount and nett salary to be displayed on screen.

- get the units sold and salary from main() to calculate the bonus amount

by refering to the following table.

- return the bonus amount to main().

UNITS SOLD BONUS

> 1000 20% of salary

501 - 1000 10% of salary

(ii) In function get_nett_salary(...) :

(iv) In function display(...)

- get the bonus amount and salary from main() to calculate the nett salary.

- return the nett salary to main()

- get staff id, salary, units sold, bonus amount and nett salary from main.

- display all information on screen.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DATA ENTRY

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter staff id : 1234

Enter staff salary : RM 3500.00

Enter total units sold : 750

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SALARY SLIP

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Staff ID : 1234

Staff salary : RM 3500.00

Units sold : 750

Bonus : RM 350.00

Nett Salary : RM 3850.00

Press any key to continue

tiger said...

can someone help me with this question?

Anonymous said...

Wrote a program that take a integer number as input from user then reverse the number and show which grade it belongs to simple input : 18 output : 81 At please give me answer.

ನಿರಂಜನ್ said...

Very nice post , many things to learn from this, But very small correction required in 20th questions output part. It says: Range of unsigned char is -128 to 127. It should be Range of signed char is -128 to 127.Please change the unsigned to signed .

Unknown said...

m.nagaraju

this is the sim[ple solution for that program
#include
#include
void main()
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
printf("#");
}
printf("\n");
}
getch();
}

Unknown said...

above the all answres r exactly right

Unknown said...

#include
#include
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
printf("#");
for(j=1;j<i;j++)
{
printf("##");
}
printf("\n");
}
getch();
}

i need tricky questions on pointers to salve;i need difficult questions

Unknown said...

how can iprint 1-50 or 50-100 numbers in linux c program
by using if-else

Unknown said...

the value of float a=0.7 will be 0.70000 .and we compare (0.70000<0.7)
condition satisfied so the answer is "c"

Unknown said...

Very nice collection.. can u plz provide a program to print hello world without main() function..

Unknown said...

I am not getting code for this pattern, can anyone of you can help me with this
the pattern is
D C B A
C B A
B A
A
I am getting o/p as
D B C A
D C B
D C
D

Unknown said...

How to print
A
B C
D E F
G H I J

Unknown said...

how to print pascal triangle exactly from the middle of screen......???all the lines shd B equidistant frm both the corners....

AGM said...

hello i have some question about what this reason of d and rep
long ppdp(long n)
{long d=2,rep=n;
if (n%2==0)
{rep=2;
}else {
d=3;
while (d*d<n && rep==n)
{if(n%d==0)
rep=d;
else
d+=2;
}
}
return rep;
}

Unknown said...

char i, j;

for (i = 65; i<=70; i++)
{
printf ("\n");
for(j=65; j<=i; j++)
printf("%c", j);
}
return 0;
}

Unknown said...

no>>9

Unknown said...

Explanation:
struct ABC{
int a;
float b;
char c;
};
int main(){
struct ABC *ptr=(struct ABC *)0;
ptr++;
printf("Size of structure is: %d",*ptr);//=>original:Here we got error
printf("Size of structure is: %d",ptr);//=>new update
return 0;
}

Thank you

Unknown said...

question 10;

output: 10

Unknown said...

question 10;

output: 10

KD said...

Write a C program using function that takes a string and a number between 0 and 9 as parameters, and displays the string that many times, and returns its length.

KD said...

Write a C program to accept the names and marks of 7 students in 5 subjects. Print in descending order the rank list based on the average of the 5 subjects. Also print the name of the first ranker and his percentage.

Unknown said...

Unknown said...

#include
main()
{
int i,k;
for(i=5;i>0;i--)
{
for(k=i;k<=5;k++)
{
printf("%d",k);
}
printf("\n");
}
}

Unknown said...

I want below pattern in C or Any Programming language
ABCCBA
AB BA
A A
AB BA
ABCCBA

Anonymous said...

#include
int main()
{
int n;
printf(¨enter n value¨);
scanf(¨%d¨,&n);
for(int i=1;i<=n;i++)
{
for int j=1;j<=i;j++)
{
printf(¨*¨);
}
printf(¨\n¨);
getch();
}

Unknown said...

#include
int main()
{
char s[7]="aspire";
for(int i=0;i<7;i++)
{
for(int j=0;j<i;j++)
{
printf("%c",s);
}
printf("\n");
}
}

Muktak Pandya said...

Using Divide and conquer technique,how can we evaluate the polynomial P(x)= a+bx+cx2+.....+ nxn at a given point x .

Unknown said...

C Programming Tips And Tricks...

https://youtu.be/TBKVuM9W8RM

Unknown said...

i need a program to find computer configuration

Unknown said...

thankyou

Unknown said...

Unknown said...

Aravin said...

Good job bro :) keep rocking...

Unknown said...

tq for qns with answrs......

Unknown said...

write a program to input a number and count the digits in it.use while loop and the program should work correctly for zero(0) also ?

Unknown said...

#include
main()
{
int n,r,c;
printf("enter n...");
scanf("%d",&n);
for(r=1;r<=n;r++);
for(c=1;c<=n;c++)
printf("%d",c+r);
printf("\n");
}

Unknown said...

Nice job!!

Unknown said...

Very good explanation (even these things are not really "basic".
For Q.17-(4), I think there is a mistake.
int ( * ( * ptr ) [ 5 ] ) ( )
ptr is a pointer to such array of size five which content are pointers to
such function which parameter is void and return type is int type data.
Should be:
ptr is a pointer to such array of size five which content are pointers to
such function which has undefined (variable) number of parameters and return type
is int type data.
Since : int Foo () is a function which takes an undefined (variable) number of
parameters. That is totally different from int Foo (void) which takes no parameter
and return type is int.

Unknown said...

Nice Explanation....Very useful for interviews

Unknown said...

int main(){
int num,i=0;

do{
printf("To enter press 1\n");
printf("To exit press 2");
scanf("%d",&num);
++i;
switch(num){
case 1:printf("You are welcome\n");break;
default : exit(0);
}
}
while(i<=10);
return 0;
}

Output: 3 3 4 4

question no 8
how come output is this??
this is wrong
we r not printing any value