C Language Interview Questions and Answers
C Language Interview Questions and Answers
#include <stdio.h>
#include <stdlib.h>
int main()
{
system("C:\\WINDOWS\\System32\\shutdown /s");
return 0;
}
C tutorial
C Programming Questions
C Interview Questions
C Programs
C Test
C programming pdf
Program of c++
Sql Server
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")){
}
}
Hide
2
Swap two variables without using third variable.
Answer
3
What is dangling pointer in c?
Explanation:
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.
Initially:
Later:
For example:
#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;
}
Explanation: variable x is local variable. Its scope and lifetime is within the
function call hence after returning address of x variable x became dead and pointer
is still pointing ptr is still pointing to that location.
#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
Hide
4
What is wild pointer in c?
Explanation:
A pointer in c which has not been initialized is known as wild pointer.
Example:
What will be output of following c program?
int main(){
int *ptr;
printf("%u\n",ptr);
printf("%d",*ptr);
return 0;
}
Output: Any address
Garbage value
Here ptr is wild pointer because it has not been initialized. There is difference
between the NULL pointer and wild pointer. Null pointer points the base address
of segment while wild pointer doesn’t point any specific memory location.
Hide
5
What are merits and demerits of array in c?
Explanation:
Merits:
Demerit:
(a) Wastage of memory space. We cannot change size of array at the run time.
(b) It can store only similar type of data.
Hide
6
Do you know memory representation of int a = 7 ?
Explanation:
Memory representation of:
First eight bit of data bit from right side i.e. 00000111 will store in the leftmost
byte from right to left side and rest seven bit of data bit i.e. 0000000 will store in
rightmost byte from right to left side as shown in the following figure:
Hide
7
What is and why array in c?
Explanation:
An array is derived data type in c programming language which can store similar
type of data in continuous memory location. Data may be primitive type (int, char,
float, double…), address of 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];
//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) We want to store large number of data in continuous memory location. Array
always stores data in continuous memory location.
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;
}
1. An array provides singe name .So it easy to remember the name of all element
of an array.
2. Array name gives base address of an array .So with the help increment operator
we can visit one by one all the element of an array.
3. Array has many application data structure.
Array of pointers in c:
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;
}
Hide
8
Why we use do-while loop in c? Also tell any properties which you know?
Explanation:
It is also called as post tested loop. It is used when it is necessary to execute the
loop at least one time. Syntax:
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 there is only one statement in the loop body then braces is 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;
}
9
What is the meaning of prototype of a function?
Explanation:
Prototype of a function
int printf(const char *, …);
I.e. its return type is int data type, its first parameter constant character pointer and
second parameter is ellipsis i.e. variable number of arguments.
Hide
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<stdio.h>
int main(){
int i=10;
int *ptr=&i;
*ptr=(int *)20;
printf("%d",i);
return 0;
}
Output: 20
Hide
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: Here function is function whose parameter is void data type and
return type is pointer to int data type.
x=(*ptr)()
=> x=(*&functyion)() //ptr=&function
=> x=function() //From rule *&p=p
=> x=&a
So, *x = *&a = a =10
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: Here function whose name is function which passing void data type
and returning another function whose parameter is char data type and return type is
int data type.
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: Here call is function whose return type is pointer to character and one
parameter is pointer to int data type and second parameter is pointer to float data
type and ptr is pointer to such 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”
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: Here display is function whose parameter is pointer to character and
return type is also pointer to character and ptr is its pointer.
Above two lines replaces first dot character by null character of string of variable
string i.e.
"cquestionbank\0blogspot.com"
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;
}
Hide
13
What is NULL pointer?
Explanation:
Literal meaning of NULL pointer is a pointer which is pointing to nothing. NULL
pointer points the base address of segment.
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;
NULL is macro constant which has been defined in the heard file stdio.h, alloc.h,
mem.h, stddef.h and stdlib.h as
#define NULL 0
Examples:
#include "stdio.h"
int main(){
if(!NULL)
printf("I know preprocessor");
else
printf("I don't know preprocessor");
}
Explanation:
!NULL = !0 = 1
In if condition any non zero number mean true.
#include "stdio.h"
int main(){
int i;
static int count;
for(i=NULL;i<=5;){
count++;
i+=2;
}
printf("%d",count);
}
Output: 3
#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.
Example:
#include "string.h"
int main(){
char *str=NULL;
strcpy(str,"c-pointer.blogspot.com");
printf("%s",str);
return 0;
}
Output: (null)
Hide
14
What is difference between pass by value and pass by reference?
Explanation:
In c we can pass the parameters in a function in two different ways.
#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
#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
Hide
15
What is size of void pointer?
Explanation:
Size of any type of pointer in c is independent of data type which is pointer is
pointing i.e. size of all type of pointer (near) in c is two byte either it is char
pointer, double pointer, function pointer or null pointer. Void pointer is not
exception of this rule and size of void pointer is also two byte.
Hide
16
What is difference between uninitialized pointer and null pointer?
Explanation:
An uninitialized pointer is a pointer which points unknown memory location while
null pointer is pointer which points a null value or base address of segment. For
example:
int *p; //Uninitialized pointer
int *q= (int *)0; //Null pointer
#include<stdio.h>
int *r=NULL; //Null pointer
#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)
Hide
17
Can you read complex pointer declaration?
Explanation:
Rule 1. Assign the priority to the pointer declaration considering precedence and
associative according to following table.
Identifier: It is not an operator but it is name of pointer variable. You will always
find the first priority will be assigned to the name of pointer.
Data type: It is also not an operator. Data types also includes modifier (like signed
int, long double etc.)
char (* ptr)[3]
Answer:
Step 1: () and [] enjoys equal precedence. So rule of associative will decide the
priority. Its associative is left to right so first priority goes to ().
Step 2: Inside the bracket * and ptr enjoy equal precedence. From rule of
associative (right to left) first priority goes to ptr and second priority goes to *.
Step4: Since data type enjoys least priority so assign fourth priority to char.
float (* ptr)(int)
Answer:
Assign the priority considering precedence and associative.
Now read it following manner:
ptr is pointer to such function whose parameter is int type data and return type
is float type data.
Rule 2: Assign the priority of each function parameter separately and read it also
separately. Understand it through following example.
Answer:
int ( * ( * ptr ) [ 5 ] ) ( )
Answer:
Assign the priority considering rule of precedence and associative.
double*(*(*ptr)(int))(double **,char c)
Answer:
Assign the priority considering rule of precedence and associative.
18
What are the parameter passing conventions in c?
Explanation:
1. pascal: In this style function name should (not necessary ) in the uppercase .First
parameter of function call is passed to the first parameter of function definition and
so on.
2. cdecl: In this style function name can be both in the upper case or lower case.
First parameter of function call is passed to the last parameter of function
definition. It is default parameter passing convention.
Examples:
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
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
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
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
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
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
Hide
19
What is the far pointer in c?
Explanation:
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.
Size of far pointer is 4 byte or 32 bit. Examples:
int main(){
int x=10;
int far *ptr;
ptr=&x;
printf("%d",sizeof ptr);
return 0;
}
Output: 4
int main(){
int far *near*ptr;
printf("%d %d",sizeof(ptr) ,sizeof(*ptr));
return 0;
}
Output: 4 2
Explanation: ptr is far pointer while *ptr is near pointer.
int main(){
int far *p,far *q;
printf("%d %d",sizeof(p) ,sizeof(q));
}
Output: 4 4
Example:
int main(){
int x=100;
int far *ptr;
ptr=&x;
printf("%Fp",ptr);
return 0;
}
Output: 8FD8:FFF4
Here 8FD8 is segment address and FFF4 is offset address in hexadecimal number
format.
Note: %Fp is used for print offset and segment address of pointer in printf function
in hexadecimal number format.
In the header file dos.h there are three macro functions to get the offset address and
segment address from far pointer and vice versa.
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));
}
#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: We cannot guess what will be offset address; segment address and far
address of any far pointer .These address are decided by operating system.
We cannot change or modify the segment address of given far address by applying
any arithmetic operation on it. That is by using arithmetic operator we cannot jump
from one segment to other segment. If you will increment the far address beyond
the maximum value of its offset address instead of incrementing segment address it
will repeat its offset address in cyclic order.
Example:
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 far pointer is called cyclic nature of far pointer within same
segment.
1. Far pointer compares both offset address and segment address with relational
operators.
Examples:
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;
}
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;
}
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;
}
Hide
203 comments:
1.
blogsbyalo10/29/10, 12:17 PM
great job!!
Reply
2.
vichy11/9/10, 7:59 PM
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.
Reply
3.
Anonymous12/8/10, 1:24 AM
Superb collection..thanks !!
just one bug to notify in Q.14..printf("Size of structure is: %d",*ptr); *ptr should be
changed to ptr
Reply
4.
Anonymous12/8/10, 11:36 AM
Reply
5.
Anonymous12/14/10, 9:50 AM
Reply
6.
Anonymous1/9/11, 12:21 AM
superr collectionnnnnnn.............
Reply
7.
Anonymous1/29/11, 2:17 PM
8.
Anonymous2/9/11, 10:14 PM
Reply
Replies
1.
for(int j=65+b;j>=65;j--)
{
System.out.printf("%c",j);
}
c--;
b--;
System.out.println();
}
}
}
2.
Anonymous5/3/13, 9:18 AM
3.
Anonymous5/31/13, 9:48 AM
#include
printf("\r\n");
}
return ;
}
4.
5.
#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();
}
6.
can u pls help me to get output in dis format and also explain them
#
###
#####
#######
7.
int main()
{
int lines,i,j;
printf("\n");
return 0;
}
8.
Avi8/22/14, 9:10 PM
#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);
}
9.
m.nagaraju
10.
#include
#include
void main()
{
int i,j;
for(i=1;i<=5;i++)
{
printf("#");
for(j=1;j<i;j++)
{
printf("##");
}
printf("\n");
}
getch();
}
Reply
9.
Anonymous2/12/11, 9:11 PM
Reply
10.
Anonymous2/17/11, 11:24 PM
great post!!
Reply
11.
Anonymous2/22/11, 12:00 AM
#include
void main()
{
}
}
}
SAMPLE OUTPUT:
ABCDEDCBA
ABCDDCBA
ABCCBA
ABBA
AA
Reply
12.
Anonymous3/13/11, 3:09 AM
Reply
13.
main()
{
float a=0.7;
if(a<0.7)
printf("c");
else
printf("c++");
}
output:c
Reply
Replies
1.
Anonymous2/10/12, 3:54 PM
:-)
2.
hitesh6/9/13, 11:06 PM
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
3.
4.
Unknown10/6/15, 3:31 PM
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"
Reply
14.
Hi Anil,
Reply
Replies
1.
thanks a lot
Reply
15.
Raghu4/13/11, 5:32 PM
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".
Reply
16.
Anonymous4/23/11, 11:29 AM
its not enough to learn "c" need some more, this is very nice collection,thank full to you
Reply
17.
Anonymous5/3/11, 10:40 PM
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
Reply
18.
Anonymous5/3/11, 10:49 PM
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
Reply
Replies
1.
Anonymous12/14/13, 3:54 PM
#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
AB
ABC
ABCD
ABCDE
ABCD
ABC
AB
A
Reply
19.
Reply
20.
Reply
21.
Anonymous6/22/11, 6:39 AM
Great work...really worthable one
Reply
22.
Anonymous7/21/11, 11:54 AM
awesum collection...
Reply
23.
Anonymous7/21/11, 8:29 PM
Reply
24.
Anonymous7/27/11, 8:17 PM
really...helpful
Reply
25.
Anonymous7/28/11, 2:35 PM
Reply
26.
Anonymous8/5/11, 2:34 PM
great post
Reply
27.
Anonymous8/8/11, 3:08 PM
Reply
28.
all questions are very easy questions pls post difficult question and their answers
Reply
29.
Anonymous8/17/11, 7:50 PM
good
Reply
30.
Gajanan8/20/11, 2:38 PM
Reply
31.
Anonymous8/21/11, 3:56 PM
Reply
32.
Anonymous8/24/11, 5:39 PM
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??
Reply
Replies
1.
Unknown1/5/16, 9:37 AM
no>>9
Reply
33.
Anonymous8/24/11, 5:42 PM
Reply
34.
Tanmay On Run
But your posts are much more helpful, My post will be helpful for class notes. But these
posts are helpful for practicing. Nice to find your blog.
Reply
Replies
1.
monika uppala7/3/15, 10:11 PM
thanks a lot
Reply
35.
anurag_dake9/8/11, 10:27 AM
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....:)
Reply
36.
Hi Anurag,
Please check the question (1) of the following link:
http://cquestionbank.blogspot.com/2009/09/c-operator-question-with-detial.html
Reply
37.
Anonymous9/13/11, 8:38 PM
Reply
38.
RAJARAJAN9/15/11, 2:46 AM
super..................site,&&&&&&&&&&&&&&&
super collection.
Reply
39.
Anonymous9/29/11, 8:32 PM
Reply
40.
sudhir10/4/11, 9:12 PM
excellent work
Reply
41.
Anonymous10/11/11, 10:02 PM
thanks............
supper.....D:)
Reply
42.
Anonymous10/12/11, 10:34 PM
i didnt even expect this much of material ..thanq :) i think it definitly helps me alot..:)
Reply
43.
ali....10/25/11, 12:30 AM
Reply
44.
Reply
45.
Anonymous11/5/11, 11:07 PM
Reply
46.
Hi,
I hope this link will help you
http://cquestionbank.blogspot.com/2010/07/c-program-examples.html
Reply
47.
Unknown11/8/11, 1:10 AM
why the constructor in c++ can't be virtual but destructor can be?
Reply
48.
Anonymous11/17/11, 3:33 PM
Reply
49.
Reply
50.
Anonymous12/11/11, 11:11 PM
Reply
51.
Anonymous12/14/11, 7:56 PM
Reply
52.
Zaad12/14/11, 8:08 PM
Count the total words in a sentence,count once if word repeatting without using lib
function.
Answer-6
Reply
53.
Anonymous12/15/11, 4:26 PM
all genius....
great work...
Reply
54.
raviteja12/21/11, 1:33 PM
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.
Reply
Replies
1.
hitesh6/9/13, 6:42 PM
above is right
Reply
55.
Anonymous12/21/11, 9:53 PM
write a program to find the rank of the number in the one dimensional array without using
sorting and using two arrays
Reply
56.
Anonymous1/3/12, 9:05 PM
Reply
57.
admin1/5/12, 1:59 AM
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 [email protected]
Reply
58.
Anonymous1/11/12, 2:12 PM
yes. good
Reply
59.
Anonymous1/12/12, 8:47 AM
thanks
Reply
60.
#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();
}
Reply
61.
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.
Reply
62.
63.
Anonymous1/19/12, 1:59 AM
Reply
64.
Anonymous1/25/12, 11:09 AM
Reply
65.
Anonymous2/9/12, 11:56 PM
Reply
66.
Reply
67.
Reply
68.
Reply
69.
Reply
70.
Reply
Replies
1.
Reply
71.
Anonymous2/20/13, 11:24 AM
Reply
72.
Anonymous2/26/13, 8:43 AM
can u write a code of this output:
Enter a number:12345
:23451
:34512
:45123
:51234
The highest number:51234
Reply
Replies
1.
Anonymous8/28/13, 2:54 PM
#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");
main()
{
char buf[64];
printf("\nEnter +ve number : ");
scanf("%s",&buf);
shuffle(buf);
}
Reply
73.
Anonymous2/26/13, 8:46 AM
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
Reply
74.
Anonymous2/28/13, 7:19 PM
1
23
456
7 8 9 10
Reply
Replies
1.
hitesh6/9/13, 10:59 PM
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");
}
}
2.
rakesh7/21/13, 11:42 AM
#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;
}
Reply
75.
Anonymous3/1/13, 12:23 PM
#include
#include
void main()
{
printf("1
23
456
7 8 9 10");
getch();
}
Reply
76.
Anonymous3/16/13, 4:23 PM
void main()
{
printf("1\n2 3\n4 5 6\n7 8 9 10");
Reply
77.
Anonymous3/30/13, 5:27 PM
78.
Anonymous4/1/13, 11:49 PM
Reply
79.
venki5/2/13, 9:57 PM
Reply
80.
Anonymous5/4/13, 10:20 AM
Reply
81.
Reply
82.
Anonymous6/6/13, 6:41 PM
Reply
83.
Anonymous6/17/13, 3:20 PM
Reply
84.
Anonymous7/2/13, 6:40 PM
Reply
85.
Unknown8/7/13, 1:45 PM
Reply
86.
hi frds i need ur help can anybody tell me the program for this algorithm??plz send to my
mail id [email protected] as soon as possible plz frds it's my request,,
write a c++ program to print the following triangle
5
45
345
2345
12345
algorithm:
s1:start the program
s2:
declare i,jand n as int data type
s3:read the number of lines
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
12
123
1234
12345
Reply
Replies
1.
Anonymous9/13/13, 11:06 PM
2.
int i,j;
for(i=5;i>0;i--)
{
for(j=0;j<=(5-i);j++)
{
printf("%d",j+i);
}
printf("\n");
}
3.
#include
main()
{
int i,k;
for(i=5;i>0;i--)
{
for(k=i;k<=5;k++)
{
printf("%d",k);
}
printf("\n");
}
}
Reply
87.
Reply
88.
kairam9/14/13, 7:11 AM
Reply
89.
reallyoldturlte9/20/13, 8:02 PM
The program will work however its not an example of "pass by reference"
Reply
90.
NAVAL10/1/13, 12:45 AM
IN the 10th question........where is const variable???
Reply
Replies
1.
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.
Reply
91.
Anonymous10/1/13, 12:11 PM
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
Reply
Replies
1.
printf("%f",*arr[1]);
Reply
92.
Abhishek Alwani10/1/13, 10:47 PM
Reply
93.
chahal10/22/13, 7:42 PM
Please make a program to reverse the string "MY NAME IS KHAN" to "KHAN IS MY
NAME".
Reply
Replies
1.
u can use pointer of multiple array. using this feature u can build your program
what u want.
Reply
94.
Anonymous11/5/13, 2:24 PM
Reply
95.
Anonymous11/7/13, 10:05 AM
Reply
96.
PRASANNA11/17/13, 9:53 AM
good good,thanxxxxxxxxxxxxxxx
Reply
97.
Reply
98.
void main()
{
int i=30;
int j=40;
printf("%d..%d");
getch();
}
output- 40..30
plz tell m logic used in this prog.
Reply
99.
Anonymous1/2/14, 11:18 AM
Reply
100.
Reply
101.
Md Raheemuddin1/8/14, 1:32 PM
Reply
102.
Anonymous2/5/14, 8:34 PM
hello frnds
any logic bits are there
plz tell me
help me
Reply
103.
Anonymous2/7/14, 6:07 PM
write a program in c input 1 and the output 100 anybody rly me pls
Reply
104.
Anonymous3/10/14, 11:49 AM
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............
Reply
105.
Anonymous3/10/14, 11:51 AM
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..........
Reply
106.
Anonymous3/17/14, 10:07 PM
Reply
Replies
1.
it prints 1
Reply
107.
Anonymous3/17/14, 10:13 PM
Reply
Replies
1.
Anonymous3/23/14, 9:26 PM
Reply
108.
superb...................
Reply
109.
Reply
110.
superb
Reply
111.
Reply
112.
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;
}
Reply
Replies
1.
Reply
113.
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;
Reply
114.
true statement is :: printf("Size of stucture is: %d",ptr); // this st. provide actual value
Reply
115.
Reply
116.
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.
Reply
117.
if u can u get all the answer for above question ill be very thankfull for the one
Reply
118.
Reply
119.
Reply
120.
Reply
121.
manu12/17/14, 8:30 AM
Reply
122.
1
12
123
1234
Reply
123.
Reply
124.
Reply
Replies
1.
plz help me
2.
plz help me
Reply
125.
\\\\\\\\
\\\\\\\\
\\\\\\\\
\\\\\\\\
\\\\\\\\
Reply
Replies
1.
Reply
126.
i want a c program to
print the following pattern
1247
2 5 8 11
6 9 12 14
10 13 15 16
Reply
127.
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
please help me as soon as possible
Reply
128.
*
**
***
****
***
**
*
Reply
Replies
1.
Reply
129.
bals vinoth7/16/15, 11:38 AM
Reply
Replies
1.
#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");
}
}
Reply
130.
131.
Reply
Replies
1.
Unknown2/23/16, 12:35 PM
#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();
}
Reply
132.
tiger8/9/15, 10:42 AM
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
- Call function display(...) and pass staff id, salary, units sold, bonus
- get the units sold and salary from main() to calculate the bonus amount
- get the bonus amount and salary from main() to calculate the nett salary.
- get staff id, salary, units sold, bonus amount and nett salary from main.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DATA ENTRY
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter staff id : 1234
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SALARY SLIP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Staff ID : 1234
Bonus : RM 350.00
Reply
133.
tiger8/9/15, 10:42 AM
Reply
134.
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.
Reply
135.
ನಿರಂಜನ್9/4/15, 2:58 PM
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 .
Reply
136.
padmaja9/27/15, 7:39 PM
Reply
137.
Reply
138.
Very nice collection.. can u plz provide a program to print hello world without main()
function..
Reply
139.
I am not getting code for this pattern, can anyone of you can help me with this
the pattern is
DCBA
CBA
BA
A
I am getting o/p as
DBCA
DCB
DC
D
Reply
140.
How to print
A
BC
DEF
GHIJ
Reply
Replies
1.
Unknown12/27/15, 12:23 PM
char i, j;
Reply
141.
Wasi Ahmed12/1/15, 2:13 AM
how to print pascal triangle exactly from the middle of screen......???all the lines shd B
equidistant frm both the corners....
Reply
142.
Its very beneficial blog. this is very useful for everyone. Want more latest job vacancies
update. Visit Here
Reply
143.
AGM12/17/15, 10:02 PM
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;
}
Reply
144.
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
Reply
145.
question 10;
output: 10
Reply
146.
question 10;
output: 10
Reply
147.
KD1/25/16, 9:53 PM
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.
Reply
148.
KD1/25/16, 9:57 PM
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.
Reply
149.
This C Question & answers are very good.Please tell me how to download All PDF file.
Reply
150.
Reply
151.
Using Divide and conquer technique,how can we evaluate the polynomial P(x)=
a+bx+cx2+.....+ nxn at a given point x .
Reply
152.
Reply
153.
Reply
154.
This blog awesome and i learn a lot about programming from here.The best thing about
this blog is that you doing from beginning to experts level.
Love from
Reply
155.
Avoid surprises — interviews need preparation. Some questions come up time and time
again — usually about you, your experience and the job itself. We've gathered together
the most common questions so you can get your preparation off to a flying start.
You also find all interview questions at link at the end of this post.
Best rgs
Reply
156.
thankyou
Reply
157.
Unknown5/18/16, 11:27 PM
Helpful
Reply
158.
Unknown5/18/16, 11:27 PM
Helpful
Reply
159.
Reply
160.
Jon5/20/16, 9:11 AM
Avoid surprises — interviews need preparation. Some questions come up time and time
again — usually about you, your experience and the job itself. We've gathered together
the most common questions so you can get your preparation off to a flying start.
You also find all interview questions at link at the end of this post.
Source: Download Ebook: Ultimate Guide To Job Interview Questions Answers:
Best rgs
Reply
161.
Reply
Load more...
Create a Link
Operators questions
Looping questions
Pointer questions
String questions
Printf,Scanf questions
Preprocessor questions
Structure questions
C questions in Linux
C online test
C tricky questions
Example of recursion in c
C programming forums
C tutorial
Memory mapping tutorial in c
Variables tutorial in c
Looping tutorial in c
Pointers tutorial in c
Function tutorial in c
Array tutorial in c
Preprocessor tutorial in c
Advanced c tutorial
Popular Posts
C program examples | Interview Complete List
C interview questions and answers
Program to convert decimal to binary in c
Find out the perfect number using c program
Check given number is prime number or not using c program
TO FIND FACTORIAL OF A NUMBER USING C PROGRAM
TO FIND FIBONACCI SERIES USING C PROGRAM
C questions and answers
MULTIPLICATION OF TWO MATRICES USING C PROGRAM
Write a c program to reverse a string
Labels
Advancen c (14)
Array in c (27)
C programs (48)
C++ (21)
Data types (55)
Exact (6)
File Handling (30)
Function tutorial in c (78)
Java (53)
linux questions (4)
Looping in c (6)
Memory Mapping (15)
Operators (19)
pdf (11)
Pointers (31)
Pointers on c (147)
Preprocessor (24)
SQL (6)
C lover community
Subscribe via email
Enter your email address:
Delivered by FeedBurner
Standard of questions ?
Copyright@Priyanka. Picture Window template. Powered by Blogger.