Test 2 C Coding

Ace your homework & exams now with Quizwiz!

Which of the following operators has right to left associativity?

!

The ____ operator captures the remainder when an integer number is divided by an integer.

%

What is the output of this program 32 bit c compiler ? int main() { printf("%%%%\n"); return 0; }

%%

What is the output of this program? #include <stdio.h> # define scanf "%s Find best course " main() { printf(scanf, scanf); return 0; } Group of answer choices

%s Find best course Find best course

What will be the output of the following C code? #include <stdio.h> void main() { int a = 5 * 3 % 6 - 8 + 3; printf("%d", a); }

-2

What is the output of this program? #include<stdio.h> int main() { printf("%d", 5.00); return 0; }

0

If the user enters 1 s 3.2, what value will be returned by the scanf()?scanf("%d %f %c", &a, &b, &c);

1

What is the output of this program ? int main() { int i=-2;= i=i+i*i++; printf("%d",i); return 0; }

1

What is the output of this program? #include<stdio.h> int main() { int x = 1, y = 2; printf("%d", x, y); return 0; }

1

What is the output of this program?#include <stdio.h>int main(){int i;i = 1, 2, 3; printf("%d", i);return 0;}

1

What is the output of this program 32 bit c compiler ? #include<stdio.h> int main() { int a = 1; printf("%d %p",a,a); return 0; }

1 00000001

What is the output of the following code? int main() { int k=1; printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE"); return 0; }

1 == 1 is TRUE

What will be the output of the following C code? #include <stdio.h> void main() { double b = 3 && 5 & 4 % 3; printf("%lf", b); }

1.000000

What will be the output of the following C code? #include <stdio.h> void main() { double b = 5 & 3 && 4 || 5 | 6; printf("%lf", b); }

1.000000

What is the output of this program ? int main() { char *p; p="%d\n"; p++; p++; printf(p-2, 13); return 0; }

13

What will be the output of the following C code? #include <stdio.h> void main() { int a = 5 * 3 + 2 - 4; printf("%d", a); }

13

What will be the output of the following C code? #include <stdio.h> void main() { int b = 6; int c = 7; int a = ++b + c--; printf("%d", a); }

14

Select the correct value of i from given options i=scanf("%d %d", &a, &b);

2

What is the output of this program? #include <stdio.h> int main() { int a, b; printf("%d", scanf("%d%d",&a,&b)); return 0; }

2

What is the output of this program ? #include<stdio.h> static struct student { int a; int b; } struct_var{2,3}; int main() { printf("%d %d",struct_var.a,struct_var.b); return 0; } Group of answer choices

2 3

What is the output of the following code? int main() { int k=2; printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE"); return 0; }

2 == 1 is FALSE 2 == 1 is TRUE

What will be the output of the following C code? #include <stdio.h> void main() { double b = 5 % 3 & 4 + 5 * 6; printf("%lf", b); } Group of answer choices

2.000000

What is the output of this program ? int main() { int a=250; printf("%1d<0x1d>\n", a); return 0; }

250

If the user enters 1 3.2 s, what value will be returned by the scanf()? scanf("%d %f %c", &s1, &s2, &s3);

3

What is the output of this program? #include <stdio.h> int main() { int main = 3; printf("%d", main); return 0; }

3

What is the output of the following code? int main() { int i=1; i=2+2*i++; printf("%d",i); return 0; }

4

What is the output of this program ? int main() { int i=-2;= i=i+i*i++; printf("%d",i); return 0; }

4

what is the output of the following code? main() { int i; i=1; i=i+2*i++ printf( "%d , i);

4

What is the output of this program? main ( ) { int i=2+3, 4>3, 1; printf( "%d" , i); }

4 5

What is the output of this program? main ( ) { float a=4.1589; printf("%2.3f\n", a); return 0; }

4.159

What is the output of this program? main ( ) { float a=4.1589; printf("%2.1f\n", a); return 0; }

4.2

What is the output of this program? main ( ) { int i=5; printf( "%d %d %d \n" , i,i<<2,i>>2); }

5 20 1

What is the output of this program ?int main(){int i=5;printf( "%d %d %d \n" , i,i&&2,i||2);return 0;}

5 5 1

What is the output of this program ? int main() { int i=5; printf( "%d %d \n" , i,i|2); return 0; }

5 7

What is the output of this program? int main() { int i=5; printf( "%d %d %d \n" , i,i<2,i>2); return 0; }

501

What will be the output of the following C code? #include <stdio.h> void main() { int a = 2 + 4 + 3 * 5 / 3 - 5; printf("%d", a); }

6

What will be the output of the following C code? #include <stdio.h> void main( { double b = 8; b++; printf("%lf", b); }

9.0 9.000000

____ is the order in which operators of the same precedence are evaluated.

Associativity

____ operators require two operands to produce a result.

Binary

What is the output of this program?int main(){printf("%c\n", ~('C'*-1));return 0;}

C

What is the output of this program?#include <stdio.h>int main(){ printf("variable! %d \n", x); return 0;}

Compile time error

A "solitaire" operator is one that operates on a single operand.

False

A posttest loop is also called an entranced-controlled loop.

False

A simple unary arithmetic expression has the form: literalValue operator literalValue.

False

A statement is a note about the code that the programmer includes so that he (or other programmers) can keep track of what the various parts of the program do.

False

An expression containing both integer and floating-point values is called a double-precision expression.

False

Data types are simply names given by programmers to computer storage locations.

False

Invoking a function is more commonly referred to as summoning the function.

False

The expression: (6 * 3 == 36 / 2) && (13 < 3 * 3 + 4) || !(6 - 2 < 5) evaluates to 1.

False

What will be the output of the following C code? #include <stdio.h> void main() { double b = 3 % 0 * 1 - 4 / 2; printf("%lf", b); }

Floating point Exception 0

What is the output of this program ? #include<stdio.h> int main() { int a = 3; printf("%d"); return 0; }

Garbage value

What is the output of this program? #include<stdio.h> int main() { printf("%d",5.25); return 0; }

Garbage value 5

What is the output of this program? #include<stdio.h> # define loop while(true) int main() { loop; printf("c-letsfind"); return 0; }

None of the above Compilation error program never ends

Which statment is true about the given code ?#include <stdio.h>int main(){printf("%d", main);return 0;}

Run time error give garbage value 3

A built-in data type is one that is provided as an integral part of the language.

True

A floating-point expression is also called a real expression.

True

A function header line is always the first line of a function.

True

An assignment statement tells the computer to assign a value to (that is, store a value in) a variable.

True

An operand can be either a literal value or an identifier that has a value associated with it.

True

Another name for a literal is a constant.

True

In every loop there must be a statement within the repeating section of code that alters the condition so that it eventually becomes false.

True

Symbolic constants can be extremely useful in constructing loops because they indicate what the number in the tested condition represents.

True

The ! operator is an unary operator.

True

The % operator is called both the modulus and remainder operator.

True

The main() function is sometimes referred to as a driver function.

True

What is the output of this program? int main() { printf("%c\n", ~('W'*-1)); return 0; }

V

Comment on the given statment:scanf("%d",i);

Will execute without any error

Data transmitted into a function at run time are referred to as ____ of the function.

arguments

Items passed to a function are always placed within the function name parentheses and are called ____.

arguments variables data types

What is the output of this program? #include<stdio.h> int main() { char str[25]; printf(" %d ",printf("c-letsfind")); return 0; }

c-letsfind 9?

The output of the following code is ____. count = 1; /* initialize count */ while (count <= 10) { printf("%d ",count); count++; /* increment count */ }

c. 1 2 3 4 5 6 7 8 9 10

What is the output of this program? char *str = "char *str = %c%s%c; main(){ printf(str, 4, str, 4);}"; int main() { printf(str, 4, str, 4); return 0; }

char*str = "char*str=%c%s%c%; main(){ printf(str, 4,str, 4);}"; main(){ printf(str, 4 , str, 4);}

What error will be generated on using incorrect specifier for the datatype being read?

compile error

A ____ statement is one or more statements contained between braces.

compound

The ____ statement is similar to the break statement but applies only to loops created with while, do-while, and for statements.

continue

The ____ statement literally loops back on itself to recheck the expression until it evaluates to 0 (becomes false).

do-while while

A(n) ____ is any combination of operators and operands that can be evaluated to yield a value.

expression

What is the qualifying input for the type specifier G?

floating point numbers in the shorter of exponential

Which statment is true about the given code ? #include <stdio.h> int main() { printf("%d", main); return 0; }

gives address of function main.

Output of this statment is : printf ( "%d" , printf ( "hello" ) );

hello5

The names of functions, as well as all of the words that are permitted in a program, that have special meaning to the compiler are collectively referred to as ____.

identifiers

A(n) ____ loop is a condition-controlled loop that terminates when a value within a valid range is entered.

input-validation

An expression containing only floating-point values as operands is called a floating-point expression, and the result of such an expression is a(n) ____ value.

integer single-precision

What is the output of this program? #include<stdio.h> int main() { int i; i = printf("letsfindcourse"); i = printf("%d ", i); printf("%d ", i); return 0; }

letsfindcourse 14 3

What is the output of this program ?#include<stdio.h>int main(){char *ptr = "Hello World";printf(ptr+2);return 0;}

llo World

A section of code that is repeated is referred to as a ____.

loop

In a(n) ____ loop the condition the tested condition does not depend on a count being achieved, but rather on a specific value being encountered.

pretest posttest condition-controlled

What is the meaning of the following C statement?scanf("%[^\n]s", ch);

read all characters except new line

what is the meaning of the following C statement? scanf("[^\n]s",ch);

read all new characters except new line

What does the C statement given below says? scanf("%7s",ch); Group of answer choices

read string with maximum 7 characters

What is the prototype of scanf function?

scanf("controlstring",arg1,arg2,arg3,....,argn);

scanf() is a predefined function in______header file.

stdio.h

total = total + num; is equivalent to ____.

total += sum;

Control string specifies the type and format of the data that has to be obtained from the keyboard.

true

The operators used for arithmetic operations are called arithmetic operators.

true

What will be the output of the following C code? #include <stdio.h> void main() { int k = 0; double b = k++ + ++k + k--; printf("%d", k); } Group of answer choices

undefined

What is the output of this program?#include <stdio.h>void main(){printf("hello\rworld\n");printf("hello\b\b\bworld\n");}

worldheworld

Which of the following operators has the lowest precedence?

||


Related study sets

Post Lab Assessment RG Water Analysis

View Set

Clinical Psychology Exam 1 Study Guide

View Set

445 Ch. 6 - Business Level Strategy

View Set

CH 14 Practice Concept Check Quiz:ECON

View Set

Certification- Types of Life Policies

View Set

chapter 4 bipolar junction transistors

View Set

Conocimientos Específicos 2019 Esp

View Set

Outcome 1: El Día de Acción de Gracias (Thanksgiving Day)

View Set