Friday, 17 May 2019
Wednesday, 1 May 2019
ch - command line argument
What is command line argument ? Also explain how to pass command line arguments to „C‟ program
Arguments that take input by user before running a program are called A) Main function arguments B) Main arguments C) Command-line arguments D) Parameterized arguments
Arguments that take input by user before running a program are called
A) Main function arguments
B) Main arguments
C) Command-line arguments
D) Parameterized arguments
Arguments that take input by user before running a program are called A) Main function arguments B) Main arguments C) Command-line arguments D) Parameterized arguments
ch- file
file
End of file is detected by
A) fend()
B) endf()
C) EOF
D) FEND
b) What is a file in C? Discuss various modes in which a file can be opened. Also discuss types of files.
true/false
While calling the fprintf() function in the format string conversion specifier %s can be used to write a character string in capital letters. FALSE
If the file to be included doesn‟t exist, the preprocessor flashes an error message. TRUE
Using fprintf function, we can print on the standard output device.
fill in the blank:
Function ___(E) fputs________ writes a line to a specified file
Write a „C Program to copy test of one file to another file.
Explain the difference between Text Mode and Binary Mode files
Explain the difference between Test mode and Binary mode files.
End of file is detected by
A) fend()
B) endf()
C) EOF
D) FEND
b) What is a file in C? Discuss various modes in which a file can be opened. Also discuss types of files.
true/false
While calling the fprintf() function in the format string conversion specifier %s can be used to write a character string in capital letters. FALSE
If the file to be included doesn‟t exist, the preprocessor flashes an error message. TRUE
Using fprintf function, we can print on the standard output device.
fill in the blank:
Function ___(E) fputs________ writes a line to a specified file
Write a „C Program to copy test of one file to another file.
Explain the difference between Text Mode and Binary Mode files
Explain the difference between Test mode and Binary mode files.
ch- Link List
link list
Write a program to add a new node to the beginning of a linked list and to the end of inked list.
Which are the demerits of linked list data structure?
true/false
A linked list is a linear data structure where each element is a separate object. TRUE
It is better to use array than a linked list, when there is a fixed size list in a program.
Define array and link list. Give one example for each showing its usage.
fill in the blank
___link list_____ data structure facilitates to insert and delete data during the program execution.
Write a program to add a new node to the beginning of a linked list and to the end of inked list.
Which are the demerits of linked list data structure?
true/false
A linked list is a linear data structure where each element is a separate object. TRUE
It is better to use array than a linked list, when there is a fixed size list in a program.
Define array and link list. Give one example for each showing its usage.
fill in the blank
___link list_____ data structure facilitates to insert and delete data during the program execution.
ch- structure
structure
In ____union_____ all elements are stored in the same memory location.
We must use __dot______ symbol to access structure members.
true/false
A union cannot be nested in a structure FALSE
size of a pointer, which points to a structure, depends on size of a structure.
2.7 All the members of a union share the same memory location.
question
Write a „C‟ program to store information (title, author, subject and book_id) of a Book using structure and display it in appropriate format
Write a C program to read following details of 50 students. Student Name,, Student Roll No, Class Display total number of students studying in Class “BCA”
b) Write two main differences between structure and union.
Define a structure Distance having two data members: cm and mm in integer. The program enters three variables and find which distance is the largest among them.
In ____union_____ all elements are stored in the same memory location.
We must use __dot______ symbol to access structure members.
true/false
A union cannot be nested in a structure FALSE
size of a pointer, which points to a structure, depends on size of a structure.
2.7 All the members of a union share the same memory location.
question
Write a „C‟ program to store information (title, author, subject and book_id) of a Book using structure and display it in appropriate format
Write a C program to read following details of 50 students. Student Name,, Student Roll No, Class Display total number of students studying in Class “BCA”
b) Write two main differences between structure and union.
Define a structure Distance having two data members: cm and mm in integer. The program enters three variables and find which distance is the largest among them.
ch- Storage Class
a) Declaration
b) Definition
c) Function
d) Error
ans a) Declaration
Variables that are alive and active throughout the program are called _____global____ variables.
___extern_____ int fun(); - the declaration indicates the presence of a global function defined outside the current module or in another file.
Global variable is initialized to __zero______ by default
What do you understand by local, global and static variables ? Explain
(c) Compare the lifetime, Scope, Initial value and storage place of all storage classes.
Explain different storage classes available in „C‟
ch- Memory Allocation
ch- function
ch- String
If the first string and the second string both are identical, then strcmp function returns:
A) A value of 0
B) Either 1 or 0
C) A value of 1
D) Any positive integer
ch- POinter
pointer
1.7 #include void fun(int *ptr)
{
*ptr=30;
}
int main()
{
int y=20; fun(&y);
printf(“%d”,y);
return 0;
}
The output of above program is
A. 20
B. 30
C. Compiler error
D. Runtime error
ans B. 30
*ptr++ is equivalent to
A) ptr++
B) *ptr
C) ++ptr
D) ++*ptr
What will be the output of the following code?
main()
{
int i=2,*j; j=&i;
printf("%d",i**j*i+*j);
}
A) Syntax error due to Invalid expression in printf
B) Print junk value
C) 16
D) 10
true /false
Two pointer variables cannot be subtracted.
Are the three declarations char **apple, char *apple[], and char apple[][] same? FALSE
The expressions *ptr++ and ++*ptr are same FALSE
Are the expression *ptr++ and ++*ptr are same? true
___pointer_______ is a variable which holds the address of another variable
A pointer that does not point to any data object is ___null_____
Write a note on pointers and its uses. What do you mean by refreshing and de-refreshing of a pointer variable.?
After incrementing a float pointer ptr by 1 it would be incremented by _(I) 4 Bytes_______________
The ______(L) *___________ operator returns the value of the variable to which its operand points.
A pointer in C which has not been initialized is known as ___wild______ pointer.
__astreek______ symbol is used access the value pointed by a pointer.
Explain about „Pointer to function „ with suitable example
Explain the relation of array and pointer with
example.
1.7 #include
*ptr++ is equivalent to
A) ptr++
B) *ptr
C) ++ptr
D) ++*ptr
What will be the output of the following code?
main()
{
int i=2,*j; j=&i;
printf("%d",i**j*i+*j);
}
A) Syntax error due to Invalid expression in printf
B) Print junk value
C) 16
D) 10
true /false
Two pointer variables cannot be subtracted.
Are the three declarations char **apple, char *apple[], and char apple[][] same? FALSE
ch-4 Array
1.5 What is right way to initialize arrays ?
a) int num[6]={2,4,12,5,45,5};
b) int n[]={2,4,12,5,45,5};
c) int n[6]={2,4,12};
d) int n[6]={2,4,12,5,45,5};
ans b) int n[]={2,4,12,5,45,5};
1.6 What will be the output of the following program? In C, if you pass an array as an argument to a function, what actually gets passed ?
a) Value of elements in array
b) First element of array
e) Base address of array
f) Address of the last element of array
ans e) Base address of array
.9 What is the maximum number of dimensions an array in C may have ?
a) 2
b) 8
c) 20
d) Theoretically no limits. the only practical limits are memory and compilers
ans d) Theoretically no limits. the only practical limits are memory and compilers
In C, if you pass an array as an argument to a function, what actually gets passed?
a) Value of elements in array
b) First element of the array
c) Base address of the array
d) Address of the last element of array
c) Base address of the array
The expressions arr and &arr same for an array of 10 integers FALSE
5 Two dimensional array is stored in memory physically as one-dimensional array.
An array elements are always stored in ___sequential____________ order.
An array that used more than two subscript is referred to as___(K) Multi-dimensional___ array.
When an array is declared, array name is defined as ________ to first element.
Write a C program tio find largest element of any Array?
What are the advantages and disadvantages of an Array ?
What are Merits and Demerits of Array in C
Write a program to reverse an array of numbers
Write a program to delete an element from a given location of an array of integers
Write a C program to find sum of lower triangular elements on matrix
Write a program that accept an array of 10 integers and a number to be deleted from the array if found. Represent deleted element with -1 and display final array. If not found print appropriate message.
Write a program to find greatest number in an array?
ch-3 Loop
loop
#include<stdio.h>
main()
{
int a,fact=1;;
printf("enter any number");
scanf("%d",&a);
for(int i=1;i<=a;i++)
fact=fact*i;
printf("%d",fact);
}
#include<stdio.h>
main()
{
int a=0,b=1,c,i;
for(i=0;i<=5;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
}
}
#include<stdio.h>
main()
{
int a=0,b=1,c,i;
printf("%d\n%d\n",a,b);
for(i=0;i<=5;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
}
}
#include<stdio.h>
main()
{
int sum=0;
for(int i=0;i<=5;i++)
sum=sum+i;
printf("%d",sum);
}
#include<stdio.h>
main()
{
int a,d=12345,m;
m=d%10;
d=d/10;
printf("m=%d\nd=%d\n",m,d);
}
#include<stdio.h>
main()
{
int d=5476,r,di,s=0;
while(d!=0)
{
r=d%10 ;
d=d/10;
s=s+r ;
}
printf("%d",s);
}
#include<stdio.h>
main()
{
char c='a';
for(int i=0;i<=4;i++)
{
for(int j=0;j<=i;j++)
{
printf("%c\t",c);
}
printf("\n");
++c ;
}
}
pyramid
1.
#include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
2.
#include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=5; i>=1; i--, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
3. #include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
for(i=rows; i>=1; i--, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
MCQ:
1. main()
{
int i=1;
while()
{
printf(“%d”,i++);
if(i>10)
break;
}
}
a) The condition in while loop is must
b) There should be a semicolon in the while loop
c) The while loop should be replaced by for loop
d) No error
ans a) The condition in while loop is must Break statement can be used to exit a loop. TRUE
main()
{
int i=1;
while()
{
printf(“%d”,i++);
if(i>10)
break;
}
}
a) The condition in while loop is must
b) There should be a semicolon in the while loop
c) The while loop should be replaced by for loop
d) No error
A programming construct in which a set of statement in a computer program can be executed repeatedly.
i. Loop statement
ii. Conditional Statement
iii. Block Statement
iv. All of the above
i. Loop statement
1.8 What will be the output of following program?
int main()
{
for(int c=1;c<5;++c);
printf(“%d”,c);
}
a) 1
b) 5
c) 6
d) 12345
b) 5
How many times is a do while loop guaranteed to loop?
a) 0
b) Infinitely
c) 1
d) Variable
c) 1
The following code for(;;) represents as infinite loop. It can be terminated by
A) Break
B) Exit(0);
C) Abort();
D) All of the mentioned.
Which of the following is not an iterative statement?
A) switch
B) while
C) do while
D) for
How many times is a do while loop guaranteed to loop?
A) 0
B) Infinitely
C) 1
D) Variable
How many times the printf statement within the while loop will be executed?
x=1;
while(x=0)
printf("hello");
A) 1
B) 0
C) infinite
D) 2
true/false
1. The following block of code sums up an input series of grades (terminated by -1)
while (grade !=-1);
total=total+grade;
counter=counter+1;
printf ”enter grade, -1 to end:”);
scanf(“%d”,&grade);
Fill in the blanks:
1. ____infinite_____ loop can be terminated using break statement.
2. ____dowhile_____ is an exit control loop
3. In do…while loop, _semicolon_______ symbol is required after condition.
4. The _____(B) continue_________ statement is used to skip a part of the statement in a loop.
Question:
Draw a flow chart to print the factorials of numbers from 1 to n where n is entered by user.
Draw a flowchart to find the fibionacci series till term <=10000
Write a program to find the sum of the digits of a number
Write a C Program to display following pattern:
A
BB
CCC
DDDD
EEEEE
Write a C program to find whether a number is palindrome or not?
Write a program to print all the Krishnamurti number from 1 to n. Here, n is user dependent. A Krishnamurti number is a number whose sum of factorial of individual digits equals the number. For example, 145 = 1! + 4! + 5! = 1 + 24+ 120 = 145.
true/false
1.0 is an example of double constant and float constant.
#include<stdio.h>
main()
{
int a,fact=1;;
printf("enter any number");
scanf("%d",&a);
for(int i=1;i<=a;i++)
fact=fact*i;
printf("%d",fact);
}
#include<stdio.h>
main()
{
int a=0,b=1,c,i;
for(i=0;i<=5;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
}
}
#include<stdio.h>
main()
{
int a=0,b=1,c,i;
printf("%d\n%d\n",a,b);
for(i=0;i<=5;i++)
{
c=a+b;
a=b;
b=c;
printf("%d\n",c);
}
}
#include<stdio.h>
main()
{
int sum=0;
for(int i=0;i<=5;i++)
sum=sum+i;
printf("%d",sum);
}
#include<stdio.h>
main()
{
int a,d=12345,m;
m=d%10;
d=d/10;
printf("m=%d\nd=%d\n",m,d);
}
#include<stdio.h>
main()
{
int d=5476,r,di,s=0;
while(d!=0)
{
r=d%10 ;
d=d/10;
s=s+r ;
}
printf("%d",s);
}
#include<stdio.h>
main()
{
char c='a';
for(int i=0;i<=4;i++)
{
for(int j=0;j<=i;j++)
{
printf("%c\t",c);
}
printf("\n");
++c ;
}
}
pyramid
1.
#include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
2.
#include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=5; i>=1; i--, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
3. #include <stdio.h>
int main()
{
int i, j, rows, k=0;
printf("Enter number of rows: ");
scanf("%d",&rows);
for(i=1; i<=rows; i++, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
for(i=rows; i>=1; i--, k=0)
{
for(j=1; j<=rows-i; j++)
{
printf(" ");
}
while(k != 2*i-1)
{
printf("* ");
k++;
}
printf("\n");
}
return 0;
}
MCQ:
1. main()
{
int i=1;
while()
{
printf(“%d”,i++);
if(i>10)
break;
}
}
a) The condition in while loop is must
b) There should be a semicolon in the while loop
c) The while loop should be replaced by for loop
d) No error
ans a) The condition in while loop is must Break statement can be used to exit a loop. TRUE
main()
{
int i=1;
while()
{
printf(“%d”,i++);
if(i>10)
break;
}
}
a) The condition in while loop is must
b) There should be a semicolon in the while loop
c) The while loop should be replaced by for loop
d) No error
A programming construct in which a set of statement in a computer program can be executed repeatedly.
i. Loop statement
ii. Conditional Statement
iii. Block Statement
iv. All of the above
i. Loop statement
1.8 What will be the output of following program?
int main()
{
for(int c=1;c<5;++c);
printf(“%d”,c);
}
a) 1
b) 5
c) 6
d) 12345
b) 5
How many times is a do while loop guaranteed to loop?
a) 0
b) Infinitely
c) 1
d) Variable
c) 1
The following code for(;;) represents as infinite loop. It can be terminated by
A) Break
B) Exit(0);
C) Abort();
D) All of the mentioned.
Which of the following is not an iterative statement?
A) switch
B) while
C) do while
D) for
How many times is a do while loop guaranteed to loop?
A) 0
B) Infinitely
C) 1
D) Variable
How many times the printf statement within the while loop will be executed?
x=1;
while(x=0)
printf("hello");
A) 1
B) 0
C) infinite
D) 2
true/false
1. The following block of code sums up an input series of grades (terminated by -1)
while (grade !=-1);
total=total+grade;
counter=counter+1;
printf ”enter grade, -1 to end:”);
scanf(“%d”,&grade);
Fill in the blanks:
1. ____infinite_____ loop can be terminated using break statement.
2. ____dowhile_____ is an exit control loop
3. In do…while loop, _semicolon_______ symbol is required after condition.
4. The _____(B) continue_________ statement is used to skip a part of the statement in a loop.
Question:
Draw a flow chart to print the factorials of numbers from 1 to n where n is entered by user.
Draw a flowchart to find the fibionacci series till term <=10000
Write a program to find the sum of the digits of a number
Write a C Program to display following pattern:
A
BB
CCC
DDDD
EEEEE
Write a C program to find whether a number is palindrome or not?
Write a program to print all the Krishnamurti number from 1 to n. Here, n is user dependent. A Krishnamurti number is a number whose sum of factorial of individual digits equals the number. For example, 145 = 1! + 4! + 5! = 1 + 24+ 120 = 145.
true/false
1.0 is an example of double constant and float constant.
ch-2 if statement
If Statement
#include<stdio.h>
main()
{
int a=0;
if(a=0)
printf("a is zero");
else
printf("not zero");
}
main()
{
int a=0,b=1;
if(a=0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
float a=1.2;
if (a==1.2)
printf("yes");
else
printf("no");
}
ans No
#include<stdio.h>
main()
{
float a=1.0;
if (a==1.0)
printf("yes");
else
printf("no");
}
ans yes
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1 || b==1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1 && b==1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(0)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
1. The conditional operator (?:) is a ____Ternary operator _______
2 ___|| ______ is a logical OR operator
3. The ___break_____ statement when executed in a switch statement causes immediate exit from the structure
4. A pair of question mark and colon is known as _conditional operator_______
Question:
Compare the use of switch statements with the use of nested if statements. Which is more convenient?
What will be the output of the following program segment?
main() { int x=3,
y=5;
if(x==3)
printf(“\n%d”,x);
else
printf(“\n%d”,y); }
.
MCQ:
What will be output if you compile and execute the following „C‟ code
void main()
{
float a=5.2;
if(a==5.2)
printf(“equal”);
else
if(a<5.2)
printf(“less than”);
else
printf(“greater than”);
}
A) Equal
B) Less than
C) Greater than
D) Compilation Error
Determine the order of evaluation of operations
within the expression A< B&&C||D>A
A) &&, ||, <, >
B) <, >, &&, ||
C) >, <, &&, ||
D) &&,<, >, ||
1.3 What is the output of this C code ?
#include
int main()
{
int x=2,y=0;
int z=y&&(y/=10);
printf(“%d\n”,z);
return 0;
}
a) 1
b) 0
c) undefined behavior due to order of evaluation
d) 2
ans b) 0
What will be the output of the following code?
main()
{
int x = 0, y = 0;
if(x > 0) if(y > 0)
printf("True");
else
printf("False");
}
A) Blank screen
B) True
C) False
D) Error because of dangling else problem
true/false
1. break keyword is mandatory in switch case structure.
Question/Answer
Write a „C‟program that displays the recommended actions depending on the color of a traffic light using the switch statement.
Explain the difference between = and == operator with example.
#include<stdio.h>
main()
{
int a=0;
if(a=0)
printf("a is zero");
else
printf("not zero");
}
main()
{
int a=0,b=1;
if(a=0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
float a=1.2;
if (a==1.2)
printf("yes");
else
printf("no");
}
ans No
#include<stdio.h>
main()
{
float a=1.0;
if (a==1.0)
printf("yes");
else
printf("no");
}
ans yes
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1 || b==1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(b>1 && b==1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(0)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(a||0)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
int a=0,b=1;
if(a||1)
if(a==0)
printf("a is zero");
else
printf("not zero\n");
printf("are you ok");
}
#include<stdio.h>
main()
{
char a;
printf("enter r,g,y");
scanf("%c",&a);
switch(a)
{
case 'r':
printf("stop");
break;
case 'g':
printf("go");
break;
case 'y':
printf("clear");
default:
printf("you enter wrong");
}
}
#include<stdio.h>
main()
{
char a;
printf("enter r,g,y");
scanf("%c",&a);
switch(a)
{
case 'r':
printf("stop");
break;
case 'g':
printf("go");
break;
case 'y':
printf("clear");
default:
printf("you enter wrong");
}
}
#include<stdio.h>
main()
{
char a;
printf("enter r,g,y");
scanf("%c",&a);
switch(a)
{
case 'r':
printf("stop");
break;
case 'g':
printf("go");
break;
case 'y':
printf("clear");
default:
printf("you enter wrong");
}
}
#include<stdio.h>
main()
{
char a;
printf("enter r,g,y");
scanf("%c",&a);
switch(a)
{
case 'r':
printf("stop");
break;
case 'g':
printf("go");
break;
case 'y':
printf("clear");
default:
printf("you enter wrong");
}
}
#include<stdio.h>
main()
{
int a=10;
(a==10?printf("yes"):printf("no"));
}
Fill in the blank:
A. Ternary operator B. Conditional Operator C. || D. break
Fill in the blank:
A. Ternary operator B. Conditional Operator C. || D. break
1. The conditional operator (?:) is a ____Ternary operator _______
2 ___|| ______ is a logical OR operator
Compare the use of switch statements with the use of nested if statements. Which is more convenient?
#include
int main()
{
int x=2,y=0;
int z=y&&(y/=10);
printf(“%d\n”,z);
return 0;
}
a) 1
b) 0
c) undefined behavior due to order of evaluation
d) 2
ans b) 0
if(x > 0) if(y > 0)
printf("True");
else
printf("False");
}
A) Blank screen
B) True
C) False
D) Error because of dangling else problem
true/false
Question/Answer
Subscribe to:
Posts (Atom)
Index
ch-1 Introduction
-
If Statement #include<stdio.h> main() { int a=0; if(a=0) printf("a is zero"); else printf("not ...
-
memory allocation Memory allocation can be done by using keyword „create‟. FALSE malloc() allocates memory from the heap and not from the...
-
file End of file is detected by A) fend() B) endf() C) EOF D) FEND b) What is a file in C? Discuss various modes in which a file ca...