Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
32 views

C Programming Basic Input - Output

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

C Programming Basic Input - Output

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

What will be the output of following program ?

Copy
#include <stdio.h>
void main()
{
printf("includehelp.com\rOK\n");
printf("includehelp.com\b\b\bOk\n");
}

1. OK
includehelp.ok
2. OK
includehelp.okm
3. includehelp.com
includehelp.okm
4. OKcludehelp.com
includehelp.okm

Answer & Explanation

2) What will be the output of following program ?

Copy
#include <stdio.h>
void main(){
unsigned char c=290;
printf("%d",c);
}

1. 34
2. 290
3. Garbage
4. ERROR

Answer & Explanation

3) What will be the output of following program ?

Copy
#include <stdio.h>
void main(){
int a=0;
a=5||2|1;
/
printf("%d",a);
}

1. 1
2. 7
3. 0
4. 8

Answer & Explanation

4) What will be the output of following program (on 32 bit compiler)?

Copy
#include <stdio.h>
int main(){
float a=125.50;
int b=125.50;
char c='A';
printf("%d,%d,%d\n",sizeof(a),sizeof(b),sizeof(125.50));
printf("%d,%d\n",sizeof(c),sizeof(65));
return 0;
}

1. 4,4,4
1,4
2. 4,4,8
1,1
3. 4,4,4
1,1
4. 4,4,8
1,4

Answer & Explanation

5) What will be the output of following program ?

Copy
#include <stdio.h>
int main(){
static char a;
static long b;
int c;
printf("%d,%d,%d",a,b,c); /
return 0;
}

1. 0,0,0
2. Garbage,Garbage,Garbage
3. Garbage,Garbage,0
4. 0,0,Gargabe

Answer & Explanation

6) What will be the output of following program ?

Copy
#include <stdio.h>
int main()
{
int ok=-100;
-100;
printf("%d",ok);
return 0;
}

1. 100
2. ERROR
3. -100
4. 0

Answer & Explanation

7) What will be the output of following program ?

Copy
#include <stdio.h>
enum numbers
{
zero, one, two, three , four=3,five,six,seven=0,eight
};
void main()
{
printf("%d,%d,%d,%d,%d,%d,%d,%d,%d",zero,one,two,three,four,five,six,seven
}

1. 0,1,2,3,3,4,5,0,1
/
2. 0,1,2,4,5,6,7,8,9
3. 0,1,2,3,3,1,2,3,4
4. 0,1,2,3,3,4,5,0,9

Answer & Explanation

8) What will be the output of following program ?

Copy
#include <stdio.h>
int main(){
int a,b,c;
a=0x10; b=010;
c=a+b;
printf("\nAddition is= %d",c);
return 0;
}

1. Addition is = 20
2. Addition is = 24
3. Addition is = Garbage
4. ERROR

Answer & Explanation

9) What will be the output of following program ?

Copy
#include <stdio.h>
int main()
{
int var=250;
printf("value of var = %d\n",var);
200+50;
"includehelp.com";
printf("%s\n","includehelp");
return 0;
}

1. value of var = 250


includehelp.com
2. value of var = 250
includehelp
3. ERROR
4. value of var = 250
Garbage /
Answer & Explanation

10) What will be the output of following program ?

Copy
#include <stdio.h>
int main()
{
int a=100;
printf("%d\n"+1,a);
printf("Value is = %d"+3,a);
return 0;
}

1. ERROR
2. 101,
Value is = 103
3. d
ue is = 100
4. 100
100

Answer & Explanation

11) What will be the output of following program ?

Copy
#include <stdio.h>
int main()
{
extern int ok;
printf("value of ok = %d",ok);
return 0;
}
extern int ok=1000;

1. Declaration error
2. value of ok = 1000.
3. Linking error
4. value of ok = 0.

Answer & Explanation

/
12) What will be the output of following program ?

Copy
#include <stdio.h>
int main()
{
int a=23;
;
;printf("%d",a);
;
return 0;
}

1. 23
2. Error
3. ;23;
4. ;23

Answer & Explanation

13) Find the output of this program,(program name is : static_ex.c)?

Copy
#include <stdio.h>
int main()
{
int intVar=24;
static int x=intVar;
printf("%d,%d",intVar,x);
return 0;
}

1. 24,24
2. 24,0
3. ERROR: Illegal Initialization
4. Run time error.

Answer & Explanation

14) Find the output of this program ?

Copy
#include <stdio.h>
int main()
{ /
int a=15;
float b=1.234;
printf("%*f",a,b);
return 0;
}

1. 1.234
2. 1.234000
3. 1.234000
4. ERROR

Answer & Explanation

15) Find the output of this program ?

Copy
#include <stdio.h>
int main()
{
float a,b;
a=3.0f;
b=4.0f;
printf("%.0f,%.1f,%.2f",a/b,a/b,a/b);
return 0;
}

1. 1,0.8,0.75
2. 0,0.7,0.75
3. 0,0.8,0.75
4. ERROR: Invalid format specifier

Answer & Explanation

16) Which is the valid identifier (variable name) to store student’s age?

1. int student-age;
2. int student_age;
3. int -age;
4. int _age;

Answer & Explanation

17) What type of declaration is it?


/
Copy
unsigned num;

1. num is an unsigned integer.


2. num is an unsigned character.
3. num is an unsigned float.
4. It’s an invalid declaration.

Answer & Explanation

18) Which statement does not require semicolon?

1. goto xyz
2. int x=20
3. #define MAX 1000
4. do{ ... }while(count<=100)

Answer & Explanation

You might also like