[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

# Variables & Data Types Questions

NA
SHSTTON
22
Solv. Corr.
16
Solv. In. Corr.
38
Attempted
0 M:0 S
Avg. Time

1 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main()
{
float i, j;
scanf(%f  %f, &i, &j);
printf(%.2f %.3f, i, j);
return 0;
}

What will be the output for the give input 12.342 and 123.4568

A12.34 123.456

B12.342 123.4568

C12 123

DCompilation Error

ENone of these

Explanation:

I see couple of issues with question.

1. there should be compliation issue with this statement - printf(%.2f %.3f, i, j);

I have tried to complie

\$ gcc -o q8 q8.c

q8.c: In function â€˜mainâ€™:

q8.c:6:8: error: expected expression before â€˜%â€™ token

scanf(%f %f,

Workspace

NA
SHSTTON
65
Solv. Corr.
65
Solv. In. Corr.
130
Attempted
0 M:0 S
Avg. Time

2 / 51

What will be output of the following "c" code?
#include<stdio.h>
void main()

{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

AI hate U

BI love U

CCompiler Error

DNone of these

Explanation:

For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession with of the value represented varies. Float takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.

Important Note:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >, <, <=, >=,!= ) .

Workspace

NA
SHSTTON
12
Solv. Corr.
58
Solv. In. Corr.
70
Attempted
0 M:0 S
Avg. Time

3 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main(){
int a=5;
static int b=a;
printf("%d %d",a,b);
return 0;
}

A5 5

B5 0

C5 null

D5 Garbage

ECompilation error

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
24
Solv. Corr.
95
Solv. In. Corr.
119
Attempted
0 M:0 S
Avg. Time

4 / 51

What will be output of the following "c" code?
#include<stdio.h>
void main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}

A5 4 3 2 1 0

BInfinite loop

CCompiler Error

D5 4 3 2 1

ENone of these

Explanation:

When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.

Workspace

NA
SHSTTON
7
Solv. Corr.
34
Solv. In. Corr.
41
Attempted
0 M:0 S
Avg. Time

5 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main(){
float x;
x=(int)5.6f*3.2f/sizeof((int)6.6);
printf("%f",x);
return 0;
}

A8.96

B9.6

C8

D2

ECompilation error

Explanation:

Variable x is initially declared as float.

In line 4-

x=(int)5.6f*3.2f/sizeof((int)6.6);

or, x=(int)5.6f*3.2f/sizeof(6);        [Since, we are typecasting 6.6 to int]

or, x=(int)5.6f*3.2f/4;                    [Since, 6 is integer type, and size of int is 4 bytes]

or, x=(int)4.48;

or, x=4;                                         [Since, 4.48 is typecasted to int]

In line 5, we are converting int x=4 to float type and we are printing it.

Hence, the output is 4.000000.

Workspace

NA
SHSTTON
23
Solv. Corr.
83
Solv. In. Corr.
106
Attempted
0 M:0 S
Avg. Time

6 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main(){
float **(*ptr)[4]=(float **(*)[4])0;
ptr+=5;
printf("%d  %d",ptr,sizeof ptr);
return 0;
}

A0 2

B5 2

C4 2

D40 2

ECompilation error

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
18
Solv. Corr.
17
Solv. In. Corr.
35
Attempted
0 M:24 S
Avg. Time

7 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main() {
extern out;
printf("%d", out);
return 0;
}
int out=100;

AUndefined reference symbol out

BCompiler Error

C100

Dgarbage Value

Explanation:

This is the correct way of writing the previous program.

Workspace

NA
SHSTTON
11
Solv. Corr.
23
Solv. In. Corr.
34
Attempted
0 M:0 S
Avg. Time

8 / 51

What will be output of the following "c" code?
#include<stdio.h>
void main()
{
extern int i;
i=20;
printf("%d",i);
}

A20

Bgarbage Value

CLinker Error : Undefined symbol "I"

DNone of these

Explanation:

extern storage class specifies to the compiler that the memory for "i" is allocated in some other program and that address will be given to the current program at the time of linking.

But linker finds that no other variable of name "i" is available in any other program with memory space allocated for it.

Hence a linker error has occurred .

Workspace

NA
SHSTTON
59
Solv. Corr.
202
Solv. In. Corr.
261
Attempted
1 M:18 S
Avg. Time

9 / 51

What will be output of the following "c" code?
Note: 32 bit compiler

#include<stdio.h>
int main(){
float **(*ptr)[4]=(float **(*)[4])0;
ptr+=5;
printf("%d  %d",ptr,sizeof ptr);
return 0;
}

A0 2

B160 8

C40 2

D80 4

ECompilation error

Explanation:

because size of float ** is 4 bytes

Workspace

NA
SHSTTON
41
Solv. Corr.
46
Solv. In. Corr.
87
Attempted
0 M:0 S
Avg. Time

10 / 51

What will be output of the following "c" code?
#include<stdio.h>
int main(){
float x;
x=(int)5.6 * 3.2/sizeof((int)6.6);
printf("%f",x);
return 0;
}

A8.96

B9.6

C4

D2

ECompilation error

Explanation:

Variable x is initially declared as float.

In line 4-

x=(int)5.6*3.2/sizeof((int)6.6);

or, x=(int)5.6*3.2/sizeof(6);        [Since, we are typecasting 6.6 to int]

or, x=(int)5.6*3.2/4;                    [Since, 6 is integer type, and size of int is 4 bytes]

or, x=(int)4.48;

or, x=4;                                         [Since, 4.48 is typecasted to int]

In line 5, we are converting int x=4 to float type and we are printing it.

Hence, the output is 4.000000.

Workspace

## C Programming Variables & Data Types Questions and Answers pdf

At C Programming topic Variables & Data Types, you will get multiple online quiz difficulty wise, which will have a total of 6 quizzes, categorized as easy, medium, and moderate level. While preparing for any Variables & Data Types, take all the list quiz and check your preparation level for that topic. Each quiz have 10 different question, which needs to be answered in 20 min., all the listed quiz here is free, however, you will get only one chance for each quiz to attempt(Take Quiz seriously), so it is always recommended to take one quiz in each section before you start solving Variables & Data Types MCQs practice question, and one after solving all the question of the respective level, you can refer back your Variables & Data Types quiz result any time or you can download it as pdf for reference.

## C Programming Variables & Data Types Customize Online Mock Test

This is own type of mock test, where At this C Programming Variables & Data Types MCQs mock test section, you will able to attempt only the questions related to Variables & Data Types, in that question will be a different level, important, and all the questions will be part of some of the mock tests across Q4interview FREE Mock test. You need to choose the topic as Variables & Data Types, and click on Double click to generate your customize mock test. While attempting the mock test you need to choose any of the one options out of given option. It is recommended to go through the direction given along with each question, as these questions will be randomly and so that same direction will not be applicable across the entire test. Once you submit your mock test, the result will be generated for Variables & Data Types Customize mock test, where your performance point points will be highlighted. Q4interview analysis every single point which helps you to improve your topic understanding and help you to know your type of mistakes and way to improve Variables & Data Types questions, by providing the same type of practice questions from practice exercise. The best part of this Variables & Data Types, all these mock tests listed here are free and you can take as Many time, as many you want. When you continue to give Variables & Data Types Customize Online Mock Test here regularly, then you will understand how much you have developed your accuracy on a topic, after that you will be able to decide how much attention you need to focus on. Your continued practice will increase your confidence, speed and thinking ability intensely, the Variables & Data Types Customize topic on which you will practice more will beneficial for you in future during campus placement.

## C Programming Variables & Data Types Quiz Online Test

The details of the C Programming Variables & Data Types quiz are as follows. There are 10 questions for you. You have to answer them in 20 minutes. Within 20 minutes you have to see the errors in the sentences given as a question. Four options are also given to you, and you have to choose your opinion. You must be confident in your answer that the choices are difficult. Therefore, below we provide you with some information about C Programming Variables & Data Types that you see and keep them in mind while answering questions.

## C Programming Variables & Data Types MCQs Practice Questions with Answer

On this Variables & Data Types section of page you will find the easiest quickest ways to solve a question, formulas, shortcuts and tips and tricks to solve various easiest methods to solve Variables & Data Types Question Quickly. It contains all the C Programming topic Variables & Data Types questions which are common in any of the preliminary exams of any company. The solution is provided along with the questions. The practice of these questions is a must as they are easy as well as scoring and asked in all the exams They will confirm the selection if all the questions attempted wisely with little practice. It is recommanded to Take Mock test based on C Programming topic and Variables & Data Types topic based quiz.

## C Programming Variables & Data Types solved examples question

You can get here fully solved Variables & Data Types examples with a detailed answer and description. You can solve Variables & Data Types problems with solutions, the questions by companies wise by filtering the questions, additionally, you can check what type of questions are being asked in IT companies Written Round from Variables & Data Types. Variables & Data Types became one of the most important sections in the entire competitive exams, Companies Campus, and entrance online test. Go through Variables & Data Types Examples, Variables & Data Types sample questions. You can Evaluate your level of preparation in Variables & Data Types by Taking the Q4Interivew Variables & Data Types Online Mock Test based on most important questions. All the Variables & Data Types practice questions given here along with answers and explanations are absolutely free, you can take any number of time any mock Test.

## Why C Programming Variables & Data Types?

In this practice section, you can practice C Programming Questions based on "Variables & Data Types" and improve your skills in order to face the interview, competitive examination, IT companies Written exam, and various other entrance tests (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

## Where can I get C Programming Variables & Data Types questions and answers with explanation?

Q4Interview provides you lots of fully solved C Programming (Variables & Data Types) questions and answers with Explanation. Solved examples with detailed answer description, explanation are given and it would be easy to understand. You can download C Programming Variables & Data Types quiz questions with answers as PDF files and eBooks.

## Where can I get C Programming Variables & Data Types Interview Questions and Answers (objective type, multiple-choice, quiz, solved examples)?

Here you can find objective type C Programming Variables & Data Types questions and answers for interview and entrance examination. Multiple choice and true or false type questions are also provided.