1.
What will be output of following c program?
#include <stdio.h>
int main(){
enum number { a=-1, b= 4,c,d,e};
printf( "%d" ,e);
return 0;
}
2.
What will be output of following c program?
#include <stdio.h>
int main(){
int i=0;
for (i=0;i<20;i++){
switch (i){
case 0:i+=5;
case 1:i+=2;
case 5:i+=5;
default: i+=4; break ;
}
printf( "%d " ,i);
}
return 0;
}
3.
What will be output of following c program?
#include <stdio.h>
int main(){
char c=-64;
int i=-32;
unsigned int u =-16;
if (c>i){
printf( "pass1" );
if (c<i)
printf( "pass2" );
else
printf( "Fail2" );
}
else
printf( "Fail1”);
if (c==i)
printf( "pass2" );
else
printf( "Fail2" );
return 0;
}
Explanation:
**
4.
What will the following program do ?
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main(){
int i;
char a[]= "String" ;
char *p= "New Sring" ;
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line no:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf( "(%s, %s)" ,a,p);
free(p);
free(a);
return 0;
} //Line no 15//
Chose correct option:
5.
In the following code segment what will be the result of the function
#include <stdio.h>
int main(){
unsigned int x=-1;
int y;
y = ~0;
if (x == y)
printf( "same" );
else
printf( "not same" );
printf( "%u %d" ,x,y);
return 0;
}
6.
What will be the result of the following program?
#include <stdio.h>
#include <string.h>
char *gxxx(){
static char xxx[1024];
return xxx;
}
int main (){
char *g= "string" ;
strcpy(gxxx(),g);
g = gxxx();
strcpy(g, "oldstring" );
printf( "The string is : %s" ,gxxx());
return 0;
}
7.
What will be result of the following program?
#include <stdio.h>
#include <malloc.h>
int myalloc( char *x, int n){
x= ( char *)malloc(n* sizeof ( char ));
memset(x,\0,n* sizeof ( char ));
}
int main (){
char *g= "String" ;
myalloc(g,20);
printf( "The string is %s" ,g);
return 0;
}
8.
What will be the result of the following program?
#include <stdio.h>
int main(){
char p[]= "String" ;
int x;
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" );
}
return 0;
}
9.
Which of the choices is true for the mentioned declaration?
const char *p;
and
char * const p;
Choose one of them:
7 comments:
nice qes
for similar ques refer to 'TEST YOUR C SKILLS' by Yashwant Kanetkar.
good questions ty helped alot...:)
wer is explanation for all the above questions
questions are very conceptual but somewhat difficult
questions are very conceptual but somewhat difficult
where is the explanation of these answers
Post a Comment