July 5, 2021 in C and CPP, Learning
PROGRAMMING AND PROBLEM SOLVING THROUGH ‘C’ LANGUAGE
1.6 If a = -11 and b = -3. What is the value of a % b?
A) – 3
B) – 2
C) 2
D) 3
July 5, 2021 in C and CPP, Learning
1.6 If a = -11 and b = -3. What is the value of a % b?
A) – 3
B) – 2
C) 2
D) 3
July 5, 2021 in C and CPP, Learning
1.5 Suppose i, j, k are integer variables with values 1, 2, 3 respectively. What is the value of
the following expression?
! (( j + k ) > (i + 5 ))
A) 6
B) 5
C) 1
D) 0
July 5, 2021 in C and CPP, Learning
1.4 What is the value of ‘average’ after the following program is executed?
main()
{
int sum, index;
float average;
sum = 0;
for( ; ; ) {
sum = sum + index;
++ index;
if (sum > = 100) break;
}
average = sum / index;
}
A) 91/13
B) 91/14
C) 105/14
D) 105/15
July 5, 2021 in C and CPP, Learning
1.3 Pick up the odd one out from the following
A) x = x – 1
B) x – = 1
C) x – –
D) x = – 1
June 28, 2021 in Learning, Technology, Tips and Tricks, Ubuntu
Many modern file systems employ a journal including NTFS, Ext3/4, XFS, HFS+, and others. The journal helps with two things, avoiding file system corruption and speeding up recovery after a failure such as a power loss or system crash. There are two major components to a file system, the data and the metadata. The data is the contents of a file, image, video, documents, and ultimately it is what gives the file system it’s value. The metadata is what describes the structure of the filesystem including how files are named, stored in directories, access permissions, file modification times, and recording areas of the disk that are in use or are free to be allocated to other files as they grow or are created. If the metadata becomes corrupted because of a system crash, it could lead to further data loss/corruption. For example, part of the disk might be selected for allocation to a file, but if it’s not recorded correctly before a crash, it might be added to the file’s list of data blocks, but still in the list of free data blocks and allocated to a second file later on. Now, there are two files that are sharing the same data blocks/content.
The journal is a place on the disk reserved for recording changes to the file system. The exact details of what is being changed it written first to the journal located in a single location on disk, then, after the journal is updated, the changes are applied to the appropriate locations on the disk which might require several writes. One the updates are done, the journal entry is marked as complete. After a crash, the system only need to examine the journal for incomplete entries and complete them to fix the file system. This speeds recovery and ensures a change is made entirely or not at all. If a block is allocated to a growing file, it will be added to the file’s block list and also marked as in use.
Also, on file systems that support journalling, most often it’s only metadata journalling to preserve the structure, but not the data itself. Full data journalling is normally quite expensive and slow, but less crucial than metadata. It’s possible to enable for data as well if needed.
Also, to complete this, there are some file systems that don’t currently offer journalling including FAT32, exFAT, Ext2, and UDF. If there’s a crash during an update, a full scan of the filesystem needs to be done to track down any errors or corruption.
June 13, 2021 in C and CPP - 1
1.2 Consider the following variable declaration
Union x{
int i;
float f;
char c;
}y;
if the size of i, f and c are 2 bytes, 4 bytes and 1 byte respectively then the size of the
variable y is:-
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 7 bytes
June 13, 2021 in C and CPP
1.1 The following is a program
Main()
{
int x = 0;
while(x<=10)
for( ; ; )
if( ++ x%10 = =0)
break;
printf(“x = %d”, x);
}
What will be the output of the above program?
A) Will print x = 10
B) Will give compilation error
C) Will give runtime error
D) Will print x = 20
June 13, 2021 in C and CPP
What is Pointer in C? How Pointers and Arrays are related?
June 13, 2021 in C and CPP
What is a Structure? Define a structure that contains the following members:
i) An integer quantity called acct_no
ii) A character called acct_type
iii) A 40-element character array called name
iv) A floating-point quantity called balance
v) A structure variable called lastpayment, of type date: defined as an integer called
month; an integer called day; an integer called year
vi) Include the user_defined data type account within the definition.
vii) Include structure variable customer, which is 100-element array of structures
called account.
June 13, 2021 in C and CPP
Write a macro that clears an array to zero.