C Programming and Data Structures Concepts

Company: nvidia_7oct

Difficulty: medium

Problem Statement

Question 1

What will be the output of the following C program? int main() { static int i; printf("%d", ++i); return 0; }

Question 2

What is the output of the following C program? main() { char str1[] = "Hello"; char str2[] = "World"; str1 = str2; printf("%s %s", str1, str2); }

Question 3

If the page size is 4KB and the logical address is 22 bits, how many entries will be in the page table?

Question 4

What operation does the following C function perform for positive integers a and b? int MyFunction(int a, int b) { int k = 0; while (a - k*b >= 0) ++k; return a - k*b; }

Question 5

What will be the output of the following C program? main() { unsigned int y = 2; int x = -2; if (x > y) printf("X is greater than Y"); else printf("Y is greater than X"); return 0; }

Question 6

What will be the output of the following C program? void main() { char *buff = "NVIDIA"; buff[0] = 'n'; printf("%s", buff); }

Question 7

What is the output of the following C++ program? template class QMS { public: T *m_pData; void PutSampleData(T* val) { m_pData = val; } T GetSampleData(T input) { return GetData(input); } int GetData(int a) { cout *gms = new QMS (); gms->PutSampleData(0); cout GetSampleData(0.0); return 0; }

Question 8

What will be the output of the following C program? main() { unsigned char ch = 0; int count = 0; while (++ch) { count++; } printf("%d", count); }

Question 9

If a singly linked list (with a tail pointer) is used to implement a queue, what is the best-case time complexity for inserting an element into the queue?