You are on page 1of 5

Sources / sites

http://www.cquestions.com/2012/02/data-type-questions-in-c.html

http://www.indiabix.com/c-programming/pointers/

For every question you work on, observe and understand why certain outcome is unexpectedly different than what should have been a
straightforward outcome. The objective of the questions is to get you familiar with the different ways C operates.

If the code generates a compilation error, then identify the reason for the error and fix it.

Questions Lesson(s) Learned


1 What is the outcome/output of the following C program, if any?

#include<stdio.h>
int main(){
long int 1a=5l;
printf("%ld",1a);
}
2 What is the outcome/output of the following C program, if any? Delete the “-“
Line 2 should read int main (void)
#include<stdio.h>
void main(){
int big=100;
int small=50;
int diff-val = big - small;
printf("%d",diff-val);
}
3 What is the outcome/output of the following C program, if any? Line 2 should read int main (void)
Output is one, condition statement true? Gives
#include<stdio.h>
void main(){ 1 variable?
int __BIG__ = 32;
int y;
y= __BIG__ && 8;
printf("%d",y);
}
4 What is the outcome/output of the following C program, if any? Void xyz=10 doesn’t care if its assigned 10,
makes int xyz unsuable when comes back in
#include<stdio.h>
void xyz=10; later code. Delete or declare xyz with int
int main(){
int xyz=20;
printf("%d",xyz);
}
5 What is the outcome/output of the following C program, if any? Cant call an integer twice

#include<stdio.h>
void main(){
int xyz=20;
int xyz;
printf("%d",xyz);
}
6 What is the outcome/output of the following C program, if any? Int main void
Prints 2040 right next to eachother even
#include<stdio.h>
void main(){ though printf on different lines
int xyz=20;{
int xyz=40;
printf("%d",xyz);
}
printf("%d",xyz);
}
7 What is the outcome/output of the following C program, if any? Error
Int main (void)
#include<stdio.h>
void main(){
int main = 80;
80
printf("%d",main);
}
8 What is the outcome/output of the following C program, if any? ERROR ABC DECLARED abc not declared

#include<stdio.h>
void main(){
int ABC=10;
printf("%d",abc);
}
9 What is the outcome/output of the following C program, if any? Variables not called out in printf statement
Output will be random
#include<stdio.h>
void main(){
int x=100,y=20,z=5;
printf("%d %d %d");
}
10 What is the outcome/output of the following C program, if any? Float a and int a conflict print %d needs to be
printf(“%f.2”,a)
#include<stdio.h>
void main(){
float a;
(int)a= 123.45;
printf("%d”,a);
}
11 What is the outcome/output of the following C program, if any? -8
void main()
{
int x = 4 - 4 * 4 + 4;
printf("%d\n", x);
}
12 Which among the following is NOT a logical or relational operator?
=
!=
==
||
&&

13 The two operators > and < are Relational

A. logical operators
B. arithmetic operators
C. equality operators
D. relational operators

14 Which of the following is an invalid assignment operator? None

A. a %= 10;
B. a /= 10;
C. a |= 10;
D. None of the mentioned

15 #include<stdio.h>
extern int x;
b
void main(){
int y=5;
printf(“x is %d y is %d\n”,x,y);
}
int x=10;
a) Compile error. Variable x is not declared in main, like variable
y.
b) x is 10 y is 5
c) x is 5 y is 10

You might also like