You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
intf1 (inta, intb)
{
if (a>b)
{
printf("A is greater than B\n");
return1;
}
else
{
printf("B is greater than A");
return0;
}
}
main()
{
if (f1(20,10) ||f1(10,20))
printf("C is fun!\n");
}
[x]
A is greater then B
C is fun!
[ ]
A is greater then B
B is greater then A
C is fun!
[ ]
A is greater then B
B is greater then A
Nothing is printed on Screen
Q3. What is the name for calling a function inside the same function?
recursion
subfunction
inner call
infinite loop
Q4. What does the declaration of variable c2 demonstrate?
main(){
charc1='a';
charc2=c1+10;
}
character arithmetic
undefined assignment
type conversion
invalid declaration
Q5. A pointer to void named vptr, has been set to point to a floating point variable named g. What is the valid way to dereference vptr to assign its pointed value to a float variable named f later in this program?
floatg;
void*vptr=&g;
f = _(float _)vptr;
f = (float *)vptr;
f = *(float *)vptr;
f = *(float)vptr;
Q6. What is this declaration an example of?
structs {
inti;
structs*s1;
structs*s2;
};
a node
a linked list
a stack
a binary tree
Q7. A C header file is a file with extension .h that contains function declarations and macro definitons to be shared between several source files. Header files are listed using the preprocessing directive #include, and can have one of the following formats: #include <fileA> or #include "fileB". What is the difference between these two formats?
The preprocessor will try to locate the fileA in same directory as the source file, and the fileB in a predetermined directory path.
The preprocessor will try to locate the fileA in the fixed system directory. It will try to locate fileB in the directory path designated by the -l option added to the command line while compiling the source code.
The file using fileA syntax must be system files, of unlimited number. fileB must be a user file at a maximun of one per source file.
The preprocessor will try to locate the fileA in a predetermined directory path. It will try to locate fileB in the same directory as the source file along with a custom directory path.
Q8. Using a for loop, how could you write a C code to count down from 10 to 1 and display each number on its own line?
[ ]
for (inti=0; i>=0, i--){
printf("%d\n", i);
}//end of loop
[ ]
inti;
for (i=1; i<=10; i++){
printf("%d", i);
}
[ ]
inti=10;
while (i>0){
printf("%d\n", i);
i--;
}
[x]
inti;
for (i=10; i>0; i--){
printf("%d\n", i);
}// end of loop
Q9. What is not one of the reserved words in standard C?
volatile
typeof
register
typedef
Q10. What does the program shown below return?
intmain(){
inta=1, b=2, c=3, d=4;
intx=a;
if (a>b)
if (b<c) x=b;
elsex=c;
return(x);
}
1
3
2
0
Q11. Using the Union declaration below, how many bytes of memory space will the data of this type occupy?