C and C++: HCL
C and C++: HCL
C and C++: HCL
HCL
{ if(x<=0)
return; ans fn(5) ....?
else f(x-1)+x;
}
4. i=20,k=0;
for(j=1;j<i;j=1+4*(i/j))
{
k+=j<10?4:3;
}
5. int i =10
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10
i++;
}
printf("%d", i); ans i=20
6. int x=5;
y= x&y
( MULTIPLE CHOICE QS)
ans : c
7. Y=10;
if( Y++>9 && Y++!=10 && Y++>10)
printf("........ Y);
else printf("".... )
ans : 13
8. f=(x>y)?x:y
a) f points to max of x and y
b) f points to min of x and y
c)error
d) ........
ans : a
9. if x is even, then
(x%2)=0
x &1 !=1
x! ( some stuff is there)
ans: b and d
16)
main()
{
int var=25,varp;
varp=&var;
varp p = 10;
fnc(varp)
printf("%d%d,var,varp);
}
(a) 20,55(b) 35,35(c) 25,25(d)55,55
static i=10;
printf("%d",i);
}
24. c programs
func() {
static int i = 10;
printf("%d",i);
i++;
}
27)Strings in Java
a)Mutable
b)variable length string
c)...
d)....
29. f(*p)
{
p=(char *)malloc(6);
p="hello";
return;
}
main()
{
char *p="bye";
f(p);
printf("%s",p);
}
what is the o/p?
ans:bye
36)size of(int)
a) always 2 bytes
b) depends on compiler that is being used
c) always 32 bits
d) can't tell
main() main()
{ {
int fact; int fact=0
long int x; for(i=1;i<=n;i++)
fact=factoral(x); fact=fact*i;
} }
if(x>1) return(x*factorial(x-1);
}
a) program 1;
b) program 2;
c) both 1 &2
d) none
38) main(){
char str[5]="hello";
if(str==NULL) printf("string null");
else printf("string not null");
}
what is out put of the program?
a) string is null b) string is not null c) error in program d) it executes but p
rint nothing
40)
void f(int *p){
static val=100;
val=&p;
}
main(){
int a=10;
printf("%d ",a);
f(&a);
printf("%d ",a);
}
what will be out put?
a)10,10
41)
struck a{
int x;
float y;
char c[10];
}
union b{
int x;
float y;
char c[10];
}
which is true?
a) size of(a)!=sizeof(b);
b)
c)
d)
42)
# define f(a,b) a+b
#defiune g(c,d) c*d
43)
main()
{
char a[10]="hello";
strcpy(a,'\0');
printf("%s",a);
}
out put of the program?
a) string is null b) string is not null c) program error d)
a) b) c) d)
45) main()
{
fork();
fork();
fork();
printf("\n hello");
}
How many times print command is executed?
46)main()
{
int i,*j;
i=5;
j=&i;
printf("\ni= %d",i);
f(j);
printf("\n i= %d",i);
}
void f(int*j)
{
int k=10;
j= &k;
}
output is
a 5 10
b 10 5
c55
d none
47) main()
{
int *s = "\0";
if(strcmp(s,NULL)== 0)
printf("\n s is null")p
else
printf("\n s is not null");
}
char *t;
t=x;
x=y;
y=t;
printf("-(%s, %s)",x,y);
}
void swap (char *x,char *y)
{
char *t;
y=x;
x=y;
y=t;
}
a).(New,Dictionary)-(New,Dictionary)
b).(Dictionary,New)-(New,Dictionary)
c).(New,Dictionary)-(Dictionary,New)
d).(Dictionary,New)-(Dictionary,New)
e).None of the above
(Ans will be b or e) check
total 3
15768 -rw-rw-rw- 2 you 29 Sep 27 12:07 old
15768 " " " " " " " " new
15274 " " 1 " 40 " " 09:34 veryold
64) In the following code segment what will be the result of the function,
value of x , value of y
{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans) a
main()
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"oldstring");
printf("The string is : %s",gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
Ans) b
if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation
char *t;
t=x;
x=y;
y=t;
printf("-(%s, %s)",x,y);
}
void swap (char *x,char *y)
{
char *t;
y=x;
x=y;
y=t;
}
a).(New,Dictionary)-(New,Dictionary)
b).(Dictionary,New)-(New,Dictionary)
c).(New,Dictionary)-(Dictionary,New)
d).(Dictionary,New)-(Dictionary,New)
e).None of the above
(Ans will be b or e) check
74) What will be the result of the following segment of the program
main()
{
char *s="hello world";
int i=7;
printf("%.*%s",s);
}
a)syntax error
b)hello w
c) Hello
d) o world
e) none
(Ans is b)
82) In the process table entry for the kernel process, the process id value is
a) 0 b) 1 c) 2 d) 255 e) it does not have a process table entry
Ans) a
84) In the following code segment what will be the result of the function, value of x ,
value of y
{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans) a
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation
1)
int i;
if i=0 then i:=1;
if i=1 then i:=0;
2)
int i;
if i=0 then i:=1;
if i=1 then i:=0;
(given that i can take only two values (1,0))
3)
int i;
if i=0 then i:=1;
else if i=1 then i:=0;
(given that i can take only two values (1,0))
4)
int m,j,i,n;
for i:=1 to n do
m:=m+j*n
a) Array overbound
b) Undeclared identifier
c) stack underflow
d) Accessing an illegal memory location
f(x,y,z)
{
y := y+1;
z := z+x;
}
main()
{
int a,b;
a := 2
b := 2;
f(a+b,a,a);
print a;
}
what is the value of a printed for three different calls in main.
loop:
if(i = 0)
i++;
i++;
j++;
if(j<= 25)
goto loop
xxx:
question1 : how many times is the loop entered
A few questions of that sort. some count fundaes. Easy one )
96) 10,20,30,40,50,60 : give the order when put in a queue and in a stack
Ans : Queue : 10,20,30,40,50,60
stack : 60,50,40,30,20,10
99)a problem with a function named 'myValue' will be given and asked to
find the value of main() for an argument of 150,
Ans : 150
MBT
101)
#include <stdio.h>
* What is wrong in the following problem
main() {
int i,j;
j = 10;
i = j++ - j++;
printf("%d %d", i,j);
}
ans: 0, 12
102)
#include <stdio.h>
* What is the output of the following problem
main() {
int j;
for(j=0;j<3;j++)
foo();
}
foo() {
static int i = 10;
i+=10;
printf("%d\n",i);
}
103)
#include <stdio.h>
#include <stdio.h>
#include <string.h>
/* This is asked in PCS Bombay walk-in-interview
* What is wrong in the following code
*/
main()
{
char *c;
c = "Hello";
printf("%s\n", c);
}
/*ans:- Hello, The code is successfully running */
104)
#include <stdio.h>
/* This problem is given in PCS BOMBAY walk-in-interview.
* What is the final value of i and how many times loop is
* Executed ?
*/
main()
{
int i,j,k,l,lc=0;
/* the input is given as 1234 567 */
printf("Enter the number string:<1234 567 >\n");
scanf("%2d%d%1d",&i,&j,&k);
for(;k;k--,i++)
for(l=0;l<j;l++) { lc++;
printf("%d %d\n",i,l);}
printf("LOOPS= %d\n", lc-1);
}
/* Ans: i = 16, and loop is executed for 169 times */
105)
#include <stdio.h>
/* This is given in PCS Bombay walk-in-interview */
/* What is the output of the following program */
main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d \n",u.a,u.b);
}
/* Ans : The latest value assigned to any of the union member
will be present in the union members so answer is
20 20
*/
106)
#include <stdio.h>
main()
{
float i, j;
scanf("%f %f", &i, &j);
printf("%.2f %.3f", i, j);
}
107)
#include <stdio.h>
/* This is given in PCS Bombay walk-in-interview
* What is the out put of the following problem ?
*/
main()
{
char *str = "12345";
printf("%c %c %c\n", *str, *(str++), *(str++));
}
/* Ans: It is not 1 2 3
* But it is 3 2 1 Why ??
*/
108)
#include <stdio.h>
/* This problem is asked in PCS Bombay Walk-in-interview
* Write a macro statement to find maximum of a,b
*/
#define max(a,b) (a>b)?a:b
main()
{
int a,b;
a=3;
b=4;
printf("%d",max(a,b));
}
/* Ans is very simple the coding is just for testing it
and output is 4 */
109)
#include <stdio.h>
/* This problem is asked in PCS Bombay
* What is the output of the following coding
*/
main()
{
int len=4;
char *st="12345678";
st = st -len;
printf("%c\n",*st);
}
/* Ans : It will print some junk value */
110)
#include <stdio.h>
main()
{
func(1);
}
func(int i){
static char *str ={ "One","Two","Three","Four"};
printf("%s\n",str[i++]);
return;
}
/* Ans:- it will give warning because str is pointer to the char but
it is initialized with more values
if it is not considered then the answer is Two */
111)
#include <stdio.h>
main()
{
int i;
for (i=1;i<100; i++)
printf("%d %0x\n",i,i);
}
/* Ans:- i is from 1 to 99 for the first format,
for the second format 1to9, ato f, 10 to 19,1ato1f, 20 to 29, etc */
113)
#include <stdio.h>
/* This problem is asked in PCS Bombay walk-in-interview
* In the following code please write the syntax for
* assing a value of 10 to field x of s and id_no 101 of s
*/
struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d\n",s..x,s.b.id_no);
}
/* Ans: The answer is st->x=10;
* st->b.id_no=101;
*/
114)
#include <stdio.h>
/* This problem was asked in PCS Bombay in a walk-in-interview
* Write a recursive function that calculates
* n * (n-1) * (n-2) * ....... 2 * 1
*/
main() {
int factorial(int n);
int i,ans;
printf("\n Enter a Number:");
scanf("%d",&i);
ans = factorial(i);
printf("\nFactorial by recursion = %d\n", ans);
}
int factorial(int n)
{
if (n <= 1) return (1);
else
return ( n * factorial(n-1));
}
115)
#include <stdio.h>
/* This problem is asked in PCS Bombay walk-in-interview
* What is the output of the following problem
*/
main(){
int j,ans;
j = 4;
ans = count(4);
printf("%d\n",ans);
}
int count(int i)
{
if ( i < 0) return(i);
else
return( count(i-2) + count(i-1));
}
116)
#include<stdio.h>
main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
}
/* statement 2 */
117)
#include <stdio.h>
* What is wrong in the following problem
main() {
int i,j;
j = 10;
i = j++ - j++;
printf("%d %d", i,j);
}
ans: 0, 12
118)
#include <stdio.h>
* What is the output of the following problem
main() {
int j;
for(j=0;j<3;j++)
foo();
}
foo() {
static int i = 10;
i+=10;
printf("%d\n",i);
}
119)
#include <stdio.h>
#include <stdio.h>
#include <string.h>
/* This is asked in PCS Bombay walk-in-interview
* What is wrong in the following code
*/
main()
{
char *c;
c = "Hello";
printf("%s\n", c);
}
/*ans:- Hello, The code is successfully running */
120)
#include <stdio.h>
/* This problem is given in PCS BOMBAY walk-in-interview.
* What is the final value of i and how many times loop is
* Executed ?
*/
main()
{
int i,j,k,l,lc=0;
/* the input is given as 1234 567 */
printf("Enter the number string:<1234 567 >\n");
scanf("%2d%d%1d",&i,&j,&k);
for(;k;k--,i++)
for(l=0;l<j;l++) { lc++;
printf("%d %d\n",i,l);}
printf("LOOPS= %d\n", lc-1);
}
/* Ans: i = 16, and loop is executed for 169 times */
121)
#include <stdio.h>
/* This is given in PCS Bombay walk-in-interview */
/* What is the output of the following program */
main() {
union {
int a;
int b;
int c;
} u,v;
u.a = 10;
u.b = 20;
printf("%d %d \n",u.a,u.b);
}
/* Ans : The latest value assigned to any of the union member
will be present in the union members so answer is
20 20
*/
122)
#include <stdio.h>
main()
{
float i, j;
scanf("%f %f", &i, &j);
printf("%.2f %.3f", i, j);
}
123)
#include <stdio.h>
/* This is given in PCS Bombay walk-in-interview
* What is the out put of the following problem ?
*/
main()
{
char *str = "12345";
printf("%c %c %c\n", *str, *(str++), *(str++));
}
/* Ans: It is not 1 2 3
* But it is 3 2 1 Why ??
*/
123)
#include <stdio.h>
/* This problem is asked in PCS Bombay Walk-in-interview
* Write a macro statement to find maximum of a,b
*/
#define max(a,b) (a>b)?a:b
main()
{
int a,b;
a=3;
b=4;
printf("%d",max(a,b));
}
/* Ans is very simple the coding is just for testing it
and output is 4 */
124)
#include <stdio.h>
/* This problem is asked in PCS Bombay
* What is the output of the following coding
*/
main()
{
int len=4;
char *st="12345678";
for(i=0; i<6; i++)
st = st -len;
printf("%c\n",*st);
}
/* Ans : It will print some junk value */
125)
#include <stdio.h>
main()
{
func(1);
}
func(int i){
static char *str ={ "One","Two","Three","Four"};
printf("%s\n",str[i++]);
return;
}
/* Ans:- it will give warning because str is pointer to the char but
it is initialized with more values
if it is not considered then the answer is Two */
126)
#include <stdio.h>
main()
{
int i;
for (i=1;i<100; i++)
printf("%d %0x\n",i,i);
}
/* Ans:- i is from 1 to 99 for the first format,
for the second format 1to9, ato f, 10 to 19,1ato1f, 20 to 29, etc */
127)
#include <stdio.h>
/* This problem is asked in PCS Bombay walk-in-interview
* In the following code please write the syntax for
* assing a value of 10 to field x of s and id_no 101 of s
*/
struct {
int x;
int y;
union {
int id_no;
char *name;
}b;
}s,*st;
main()
{
st = &s;
st->x=10;
st->b.id_no = 101;
printf("%d %d\n",s.x,s.b.id_no);
}
/* Ans: The answer is st->x=10;
* st->b.id_no=101;
*/
128)
#include <stdio.h>
/* This problem was asked in PCS Bombay in a walk-in-interview
* Write a recursive function that calculates
* n * (n-1) * (n-2) * ....... 2 * 1
*/
main() {
int factorial(int n);
int i,ans;
printf("\n Enter a Number:");
scanf("%d",&i);
ans = factorial(i);
printf("\nFactorial by recursion = %d\n", ans);
}
int factorial(int n)
{
if (n <= 1) return (1);
else
return ( n * factorial(n-1));
}
129)
#include <stdio.h>
/* This problem is asked in PCS Bombay walk-in-interview
* What is the output of the following problem
*/
main(){
int j,ans;
j = 4;
ans = count(4);
printf("%d\n",ans);
}
int count(int i)
{
if ( i < 0) return(i);
else
return( count(i-2) + count(i-1));
}
130)
#include<stdio.h>
main()
{
int i=4;
if(i=0)
printf("statement 1");
else
printf("statement 2");
}
/* statement 2 */
132) One questin is given, long one, to find the answer U should be
femiliar with the operation as follows
int *num={10,1,5,22,90};
main()
{
int *p,*q;
int i;
p=num;
q=num+2;
i=*p++;
print the value of i, and q-p, and some other operations are there.
}
how the values will change?
134)
char *a[4]={"jaya","mahe","chandra","buchi"};
what is the value of sizeof(a)/sizeof(char *)
a. 4 b.bytes for char c-- d.--
( we don't know the answer)
a. error at runtime
b. compilation error
c.2 3
d. 3 2
136)
#define scanf "%s is a string"
main()
{
printf(scanf,scanf);
}
what is the output.
137)
i=2+3,4>3,1;
printf("%d"i);
ans is 5 only.
138)
char *p="abc";
char *q="abc123";
while(*p=*q)
{
print("%c %c",*p,*q);
}
a. aabbcc
b. aabbcc123
c. abcabc123
d. infinate loop ( this may be correct)
139)
printf("%u",-1)
what is the value?
a. -1 b. 1 c. 65336 d. --
140)
#define void int
int i=300;
void main(void)
{
int i=200;
{
int i=100;
print the value of i;
}
print the value of i
}
what is the output?
141)
int x=2;
x=x<<2;
printf("%d ",x);
ANS=8;
142)
144) When the fn. is called where the return add. is stored?
ans. stack
151) supposing thaty each integer occupies 4 bytes and each charactrer
1 byte , what is the output of the following programme?
#include<stdio.h>
main()
{
int a[] ={ 1,2,3,4,5,6,7};
char c[] = {' a','x','h','o','k'};
printf("%d\t %d ", (&a[3]-&a[0]),(&c[3]-&c[0]));
}
ans : 3 3
ans : 9 6 3 8 5 2 7 4 1
154)
fun(n);
}
int fun( int n)
{
int i;
for(i=0;i<=n;i++)
fun(n-i);
printf(" well done");
}
howmany times is the printf statement executed for n=10?
ans: zero
expl: Befire reaching to printf statement it will goes to infinite loop.
ans:5
expl: here it evaluates as a++ + b.
159) which of the following is the correct declaration for the function main() ?
ans: main( int , char *[])
161) printf("%d%x\n",ox2,12);
163)enum
{ELLIPSE,
TRIANGLE,
RECTANGLE,
SQUARE=100,
CIRCLE=5
}
printf{"%d%d%d%d\n",TRIANGLE-RECTANGLE,SQUARE*CIRCLE-
RECTANGLE};
170)
main()
{
int i=10;
printf("%d",i);
{
int i=20;
printf("%d",i);
}
printf("%d",i);
}
171)struct class
{
int i;
float a;
string[12];
}
sizeof(class)=?
173) fact(5)
int n;
fact(n)
{
sum=n*fact(n-1);
}
174)main()
{
char a[2];
*a[0]=7;
*a[1]=5;
printf("%d",&a[1]-a)
ANS:
ans may be 1.(illegal initialization)
175)
#include<stdio.h>
main(){
char a[]="hellow";
char *b="hellow";
char c[5]="hellow";
printf("%s %s %s ",a,b,c);
printf(" ",sizeof(a),sizeof(b),sizeof(c));
}
(ans is hellow,hellow,hellow
6,2,5 )
176)
#include<stdio.h>
main()
float value=10.00;
printf("%g %0.2g %0.4g %f",value,value,value,value)
}
(ans is 10,10,10,10.000000)
177)
#include<stdio.h>
void function1;
int i-value=100;
main()
{
i-value=50;
function1;
printf("i-value in the function=",i-value);
printf("i-value after the function=",i-value);
}
printf("i-value at the end of main=",i-value);
functioni()
i-value=25;
178)
main()
{
funct(int n);
{
switch(n)
case1:
m=2;
break;
case2:
m=5;
break;
case3:
m=7;
break;
default:
m=0;
}
THIS IS ROUGH IDEA:
(ANS:Out put is m=0)
179) 2.Java is
a. compiled
b. interpreted.
c. OOP
d. mutithreaded.
e. all
ans e.
181) n=7623
{
temp=n/10;
result=temp*10+ result;
n=n/10
}
Ans : 3267
Ans: b
192)main()
{char a[10]={1,2,3,4,5,6};int x;
for(x=0;x<4;x++){ b[x]=x+'a';}
printf("%s",b);} Ans:abcd56
200)class X{
public:X(){ cout<<"This is Base";}
};
class Y:public X
{ public:Y(){cout<<"This is Derived";}};
what is printed when an object of Y is created?
201)
main()
{
int x=10,y=15;
x=x++;
y=++y;
printf("%d %d\n",x,y);
}
202)
int x;
main()
{
int x=0;
{
int x=10;
x++;
change_value(x);
x++;
Modify_value();
printf("First output: %d\n",x);
}
x++;
change_value(x);
printf("Second Output : %d\n",x);
Modify_value();
printf("Third Output : %d\n",x);
}
Modify_value()
{
return (x+=10);
}
change_value()
{
return(x+=1);
}
203)
main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf("%d %d\n",x,y);
}
204)
main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
205)
main()
{
int x=5;
printf("%d %d %d\n",x,x<<2,x>>2);
}
206)
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf("%d %d\n",x,y);
swap2(x,y);
printf("%d %d\n",x,y);
}
207)
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}
208)
main()
{
char *ptr = "Ramco Systems";
(*ptr)++;
printf("%s\n",ptr);
ptr++;
printf("%s\n",ptr);
}
209)
#include<stdio.h>
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}
210)
#include<stdio.h>
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,"Ramco");
strcpy(p2,"Systems");
strcat(p1,p2);
printf("%s",p1);
}
211)
enum day = { jan = 1 ,feb=4, april, may}
what is the value of may?
a)4 b)5 c)6 d)11
e)none of the above
212)
main
{
int x,j,k;
j=k=6;x=2; ans x=1
x=j*k;
printf("%d", x);
212)
fn f(x)
{ if(x<=0)
return; ans fn(5) ....?
else f(x-1)+x;
}
213)
i=20,k=0;
for(j=1;j<i;j=1+4*(i/j))
{
k+=j<10?4:3;
}
printf("%d", k); ans k=4
214)
int i =10
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10
i++;
}
printf("%d", i); ans i=20
215)
int x=5;
y= x&y
( MULTIPLE CHOICE QS)
ans : c
216)
Y=10;
if( Y++>9 && Y++!=10 && Y++>10)
printf("........ Y);
else printf("".... )
ans : 13
217)
f=(x>y)?x:y
a) f points to max of x and y
b) f points to min of x and y
c)error
d) ........
ans : a
219)
which of the function operator cannot be over loaded
a) <=
b)?:
c)==
d)*
ans: b and d
220) 2)#include<iostream.h>
main()
{
printf("Hello World");
}
the program prints Hello World without changing main() the o/p should
be
intialisation
Hello World
Desruct
the changes should be
a)iostream operator<<(iostream os, char*s)
os<<'intialisation'<<(Hello World)<<Destruct
b) c) d)none of the above
226)struct {
int x;
int y;
}abc;
you can not access x by the following
1)abc-->x;
2)abc[0]-->x;
abc.x;
(abc)-->x;
a)1,2,3
b)2&3
c)1&2
d)1,3,4
234) if a row daminated two dimentional arry in the following which one is advantage
and why?
a) for(i=0;i<1000;i++)
for(j=0;j<1000;j++)
temp=temp+a[i][j];
b) for(j=0;j<1000;j++)
for(i=0;i<1000;i++)
temp=temp+a[i][j]
char *t;
t=x;
x=y;
y=t;
printf("-(%s, %s)",x,y);
}
void swap (char *x,char *y)
{
char *t;
y=x;
x=y;
y=t;
}
a).(New,Dictionary)-(New,Dictionary)
b).(Dictionary,New)-(New,Dictionary)
c).(New,Dictionary)-(Dictionary,New)
d).(Dictionary,New)-(Dictionary,New)
e).None of the above
238) In the following code segment what will be the result of the function, value
of x , value of y
{
unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf("same");
else
printf("not same");
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
Ans) a
if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation
255) how does the C compiler interpret the following two statements
p=p+x;
q=q+y;
a.p=p+x;
q=q+y
b.p=p+xq=q+y
c.p=p+xq;
q=q+y
d.p=p+x/q=q+y
a.int
b.char
c.string
d.float
264) a=0;
while(a<5)
printf("%d\n",a++);
how many times does the loop occurs?
a.infinite
b.5
c.4
d.6
267) which of the following go out of the loopo if expn 2 becoming false
a.while(expn 1){...if(expn 2)continue;}
b.while(!expn 1){if(expn 2)continue;...}
c.do{..if(expn 1)continue;..}while(expn 2);
d.while(!expn 2){if(expn 1)continue;..}
271)
# define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10)); }
float n8;
} TUDAT;
279) CHAR A[10][15] AND INT B[10][15] IS DEFINED
WHAT'S THE ADDRESS OF A[3][4] AND B[3][4]
IF ADDRESS OD A IS OX1000 AND B IS 0X2000
main()
{
int i;
printf("\n %d",i);
f(&i);
printf("\n %d",i);
}
1.10,5
2,10,10
c.5,5
d. none
281) main()
{
int i;
fork();
fork();
fork();
printf("----");
}
6.
void f(int i)
{
int j;
for (j=0;j<16;j++)
{
if (i & (0x8000>>j))
printf("1");
else
printf("0");
}
}
what's the purpose of the program
282)
#define f(a,b) a+b
#define g(a,b) a*b
main()
{
int m;
m=2*f(3,g(4,5));
printf("\n m is %d",m);
}
283)
main()
{
char a[10];
strcpy(a,"\0");
if (a==NULL)
printf("\a is null");
else
printf("\n a is not null");}
284)
char a[5]="hello"
a. in array we can't do the operation .
b. size of a is too large
c. size of a is too small
d. nothing wrong with it .
union b
{
char a;
int b;
int c;
};
which is correct .
a. size of a is always diff. form size of b.(ans.)
b. size of a is always same form size of b.
c. we can't say anything because of not-homogeneous (not in ordered)
d. size of a can be same if ...
289)
#define SUM(a,b) a+b
main()
{
a=2;
b=3;
x=SUM(a,b)*2;
printf("x=%d\n",x);
}
Ans:8.
290)number(int i)
{
number++;
printf("%d\n",number);
}
main()
{
static int i=0;
number(i);
}
Ans: I don't know
291) main()
{
unsigned char i;
int sum;
main()
{
int i=10;
printf("i=%d\n", i);
fn(&i);
printf("i=%d\n", i);
}
Ans : i=10 i=10
293) Swapping without using a temporary variables. (2 methods)
(i) x = x+y;
y = x-y;
x = x-y;
(ii) x = x^y;
y = x^y;
x = x^y;
294) main()
{
int a[10] = {1, 2, 3, ...., 10}, i, x=10, temp;
Code 1 :
for(j=0; j<V_L_I; j++)
for(i=0; i<V_L_I; i++)
array[i][j] = 1;
Ans : Code 2
300)for(i=1;i<10;++i,printf("%d",i));+-
ANS:compiling error.
char *string;
string=malloc(5*sizeof(char));
strcpy(string,"hello");
printf("%s",string); /* func to print */
302) in a system integer takes 3bytes and char takes 1byte .......
struct smthing{
int a;
char b[4];
};
311) what is the output of the program segament belowif the compiler operates
call byreference?
procedure CALC(P,Q,R);
begin
Q:=Q-1.0
R:=Q+P
end;
begin{main}
A:=2.5; B:=9.0;
CALC(B-A,A,A);
print(A);
end; {main}
a) 1.5
b) 2.5
c) 10.5
* d) 8
e) 6.5
313) What will be the value of x and y after execution of the follwing
statment ( C language)
n== 5; x = n++; y = --x;
a) 5,4
b) 6,5
c) 6,6
* d) 5,5
327)o/p=?
int i;
i=1;
i=i+2*i++;
printf(%d,i);
ans: 4
329)#include<malloc.h>
char *f()
{char *s=malloc(8);
strcpy(s,"goodbye")}
main()
{
char *f();
printf("%c",*f()='A');
o/p=?
330) #define MAN(x,y) (x)>(y)?(x):(y)
{ int i=10;j=5;k=0;
k= MAX(i++,++j)
printf(%d %d %d %d,i,j,k)}
ans:10 5 0
331)
a=10;b=5; c=3;d=3;
if(a<b)&&(c=d++)
printf(%d %d %d %d a,b,c,d)
else printf("%d %d %d %d a,b,c,d);
ans:
332)
what is o/p
#include<stdarg.h>
show(int t,va_list ptr1)
{
int a,x,i;
a=va_arg(ptr1,int)
printf("\n %d",a)
}
display(char)
{int x;
listptr;
va_star(otr,s);
n=va_arg(ptr,int);
show(x,ptr);
}
main()
{
display("hello",4,12,13,14,44);
}
a) 13 b) 12 c) 44 d) 14
333)
main()
{
printf("hello");
fork();
}
ans:
334)
main()
{
int i = 10;
printf(" %d %d %d \n", ++i, i++, ++i);
}
ans:
335)
#include<stdio.h>
main()
{
int *p, *c, i;
i = 5;
p = (int*) (malloc(sizeof(i)));
printf("\n%d",*p);
*p = 10;
printf("\n%d %d",i,*p);
c = (int*) calloc(2);
printf("\n%d\n",*c);
}
ans:
336)
#define MAX(x,y) (x) >(y)?(x):(y)
main()
{
int i=10,j=5,k=0;
k= MAX(i++,++j);
printf("%d..%d..%d",i,j,k);
}
ans:
337)
#include <stdio.h>
main()
{
enum _tag{ left=10, right, front=100, back};
printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back);
}
ans:
338)
main()
{
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}
ans:
339)
#define PRINT(int) printf("int = %d ",int)
main()
{
int x,y,z;
x=03;y=02;z=01;
PRINT(x^x);
z<<=3;PRINT(x);
y>>=3;PRINT(y);
}
ans:
340)
#include<stdio.h>
main()
{
char s[] = "Bouquets and Brickbats";
printf("\n%c, ",*(&s[2]));
printf("%s, ",s+5);
printf("\n%s",s);
printf("\n%c",*(s+2));
}
ans:
341)
main()
{
struct s1
{
char *str;
struct s1 *ptr;
};
static struct s1 arr[] = { {"Hyderabad",arr+1},
{"Bangalore",arr+2},
{"Delhi",arr}
};
struct s1 *p[3];
int i;
for(i=0;i<=2;i++)
p[i] = arr[i].ptr;
printf("%s\n",(*p)->str);
printf("%s\n",(++*p)->str);
printf("%s\n",((*p)++)->str);
}
ans:
342)
main()
{
char *p = "hello world!";
p[0] = 'H';
printf("%s",p);
}
ans:
343)m=3 while (m<18) do {m=m+2;m=m-1}
ans:15
347)a=2;b=1;x=1;while(x<=4)do {a=a+b;x=x+1}
ans:(5,1)34*)
349)a=0;b=0;x=1;while (x<=4){a=a+x;b=b-x;x=x+1;}
ans:(10,-10)
}
This won't go into the loop as TRUE is defined as