This site works best with JavaScript enabled
Sign In
Discussions
Activity
Sign In
All
001 C Programming, Data Structures
Issues, queries and suggestions related to C, C programming, data structures using C and C based projects.
001 C Programming, Data Structures
Interview Questions: Project 01
spatlou
August 2017
Please post the Interview Questions and Answers related to Data Structures using C on Linux
dks.gahlot
December 2017
1. Find the intersection and union of two linked list ( L1 = 1->2->3->4->5 ) and (L2 = 3 -> 5 ->6 ) and result put in third linked list (L3) ?
2. Sort the given string.
Input
Output
This is test. -------> ehiisssttt
Note: Remove spaces,comma,dot and other symbols.
kartik.gupta
January 2018
Ans of above Ques.
2. Sort the given string
int main()
{
char *buff,*temp;
int i=0,j=0,k=0,index=0;
char smallest,tmp;
buff=(char*)malloc(sizeof(char)*20);
temp=(char*)malloc(sizeof(char)*20); //temp mem to store the the string to sort
printf("Enter the string\n");
fgets(buff,100,stdin);
buff[strlen(buff)-1]='\0'; //excludes the \n placed in the scanned string
printf("string length is %d\n",strlen(buff));
printf("string entered is %s\n",buff);
while(*(buff+i)!='\0')
{
if(*(buff+i)>=97 && *(buff+i)<=122) //to preserve small letters
{
*(temp+k++)=*(buff+i);
}
if(*(buff+i)>=65 && *(buff+i)<=90) //to make uppercase letter to lowercase and preserve it
{
*(temp+k++)=*(buff+i)+32;
}
i++;
}
*(temp+k)='\0';
printf("string to sort is %s\n",temp); //final string to sort (spaces,'.',and other special characters removed)
for(i=0;i<strlen(temp);i++)
{
smallest=*(temp+i);
index=i;
for(j=i+1;j<strlen(temp);j++)
{
if(*(temp+j)<smallest)
{
smallest=*(temp+j);
index=j;
}
}
tmp=*(temp+i);
*(temp+i)=*(temp+index);
*(temp+index)=tmp;
}
strcpy(buff,temp);
printf("sorted string is %s\n",buff);
return 0;
}
~
kartik.gupta
January 2018
Q1.Modified:
Given two link lists say L1: 1->2->3->4->6->null and L2: 2->4->6->8->null.
L3:output list should be L3: 2->4->6->null (intersection nodes of L1 and L2)
We have to first take input in manner:
->ask for the elements in first list
->take input of first 1 2 3 4 6 separated by spaces
->ask for the elements in second list
->take input of second 2 4 6 8 separated by spaces
->output the resultant list L3: 2->4->6->null
kartik.gupta
January 2018
main
{
int i,size1,size2;
node *link1,*link2,*link3,*new=NULL;
int *arr1,*arr2;
printf("Enter the size of list1\n");
scanf("%d",&size1);
printf("Enter the size of list2\n");
scanf("%d",&size2);
arr1=(int*)malloc(sizeof(int)*size1);
if(!arr1)
perror("malloc");
arr2=(int*)malloc(sizeof(int)*size2);
if(!arr2)
perror("malloc");
printf("Enter elements of list 1 in arr1\n");
for(i=0;i<size1;i++)
{
scanf("%d",arr1+i);
}
printf("Enter elements of list 2 in arr2\n");
for(i=0;i<size2;i++)
{
scanf("%d",arr2+i);
}
for(i=0;i<size1;i++)
{
if(i==0)
{
link1=createNode();
link1->data=*(arr1+i);
}
else
{
new=createNode();
new->data=*(arr1+i);
insertNode(link1,new);
}
}
for(i=0;i<size2;i++)
{
if(i==0)
{
link2=createNode();
link2->data=*(arr2+i);
}
else
{
new=createNode();
new->data=*(arr2+i);
insertNode(link2,new);
}
}
printf("list1 is \n");
displayList(link1);
printf("list2 is \n");
displayList(link2);
CommonList(&link3,link1,link2);
printf("list3 is \n");
displayList(link3);
return 0;
}
node* insertEnd(node* result,node *link)
{
node *temp=NULL;
temp=result;
if(temp==NULL)
temp=link;
else
{
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=link;
}
return temp;
}
int CommonList(node**linkref,node *link1,node *link2)
{
node *result,*temp=NULL;
*linkref=result;
while(link1!=NULL && link2!=NULL)
{
if(link1->data > link2->data)
link2=link2->next;
else
if(link1->data < link2->data)
link1=link1->next;
else //equal
{
temp=link1->next;
link1->next=NULL;
result=insertEnd(result,link1); //either link1 or link2
link2=link2->next;
link1=temp;
}
}
*linkref=result;
return 0;
}
node* createNode()
{
node *crnode=NULL;
crnode=(node*)malloc(sizeof(node));
if(!crnode)
perror("malloc");
crnode->next=NULL;
return crnode;
}
int insertNode(node *link,node *new)
{
node *temp=NULL;
temp=link;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=new;
return 0;
}
int displayList(node *link)
{
node *temp;
temp=link;
printf("strt->%p\n",temp);
while(temp!=NULL)
{
printf("data->%d & next->%p\n",temp->data,temp->next);
temp=temp->next;
}
return 0;
}
kartik.gupta
February 2018
Q. Reverse the linked list without recursion (using one loop)
A.
/*reverse the link list*/
link *curr=NULL;
link *fwd=NULL;
link *fwdFwd=NULL;
curr=strt;
fwd=curr->next;
fwdFwd=fwd->next;
curr->next=NULL; //last node is pointing to null
while(fwdFwd)
{
fwd->next=curr;
curr=fwd;
fwd=fwdFwd;
fwdFwd=fwd->next;
}
fwd->next=curr;
curr=fwd;
//last node of original list becomes the current node
printf("list reverse without recursion is:\n");
displayList(curr);
kartik.gupta
February 2018
C mostly asked basic questions' set:
https://aticleworld.com/embedded-c-interview-questions-2/#.Wn8yGY9aVjc.linkedin
Add a Comment
Powered by
Vanilla
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
0
000 Linux System Administration
25
001 C Programming, Data Structures
101
» 001.01.Introduction to C
1
» 001.16.Structures
21
002 OOPs using C++ with Eclipse on Linux
23
» 002.06.Streams and File Processing
1
003 Linux System Programming
375
» 003.01.Processes-and-Resources-Utilization
26
» 003.01.91.Interview-Questions-Introductory-Concepts
20
» 003.01.92.Interview-Questions-Introductory-Concepts
5
» 003.02.Process-Management. Introduction
21
» 003.02.91.Interview Questions. Intro-to-Processes
20
» 003.03.Process-Management - Process Duplication
91
» 003.03.92.Interview-Questions-Process-Duplication
20
» 003.03.93.Interview-Questions-Process-Duplication
20
» 003.03.94.Interview-Questions-Process-Duplication
20
» 003.03.95.Interview-Questions-Process-Duplication
20
» 003.03.96.Interview-Questions-Process-Duplication
10
» 003.04.Process-Management - Process Replacement
67
» 003.04.81.Assignment. Process Replacement
24
» 003.04.91.Interview-Questions-Process-Replacement
20
» 003.04.92.Interview-Questions-Process-Replacement
22
» 003.05.01.Inter-Process-Communication. Pipes
22
» 003.06.Inter Process Communication. FIFOs
21
» 003.07.Signals and Handlers
43
» 003.07.91.Assignment. Signals and Handlers
20
» 003.07.92.Assignment. Signals and Handlers
22
» 003.08.Inter Process Communication Message Queues
1
» 003.09.Inter Process Communication. Shared Memory
1
» 003.10.Synchronization Techniques. Semaphore
21
» 003.11.POSIX-Threads
21
004 Linux Network Programming
34
» 004.01.Introduction to Networks and Configurations
1
» 004.02.Networking Basics
1
» 004.03.Introduction-to-Sockets
21
» 004.04.Linux Network stack
1
» 004.05.Transmission Control Protocol
1
005 Character Device Drivers Development
32
» 005.01.Introduction To Device Drivers
11
006.Project Evolution with GitLab
2
» 01.Introduction To GitLab
1
008 Block Device Driver Development
4
» 008.01.Introduction to Block Device Drivers
1
009 Embedded Linux-ARM. Storage
91
» 009.01.Linux Boot Process
28
» 009.01.14.Linux-Boot-Process
5
» 009.01.15.Introduction to BIOS
0
» 009.01.16.Introduction-to-BIOS-IQs
5
» 009.01.18.Introduction-to-BIOS-IQs
5
» 009.01.20.BIOS CMOS UEFI. IQs
5
» 009.02.Introduction To Embedded Linux
1
» 009.03.01.ARM Processor Architecture
1
» 009.03.02.Programmers Model
1
» 009.04.Boot Loaders
50
» 009.05.Understanding-ARM-Board-Bringup
1
» 009.06-Board Bringup Raspberry Pi
1
» 009.06.Board Bringup. Raspberry Pi4
1
010 Embedded Linux ARM, Configuring and Porting using Storage
0
011 Shell Scripting using Bash
90
» 011.01.Introduction to Shells and Shell Scripts
1
» 011.02.Basics of Shell Scripting - Bash
1
» 011.03.Conditions and Branching
23
» 011.04.Loops and Iterations/
31
» 011.04.81.Assignment. Branching and Looping
10
» 011.05.Reserved-Words-Bullitin-Commands-Command-Line-Parsing
1
» 011.06.Parameters and Variables
1
» 011.07.Structured Scripting. Functions
11
» 011.08.Arrays-Strings-in-bash
11
» 011.09.File Operations and Commands
1
» 011.10.Writing-Manual-Pages
1
» 011.11.Makefile
1
» 011.12.sed-awk
1
012 Linux Kernel Architecture and Internals
3
014. Linux Network Administration
296
» 014.01.Intro to NW and Configurations
220
» 014.01.12.Introduction to Networking
10
» 014.01.14.Packets-IQs
10
» 014.01.16.NetworkLayers
10
» 014.01.18.The Internet Layer
20
» 014.01.20.routes and the kernel routing table
10
» 014.01.22.The Default Gateway
5
» 014.01.24.IPv6 Addresses And Networks
20
» 014.01.26.Basic ICMP And DNS Tools
10
» 014.01.28.The Physical Layer And Ethernet
5
» 014.01.30.Understanding Linux Network Interface
5
» 014.01.32.Intro To Network Interface Configuration
5
» 014.01.34.Boot Activated Network Configuration
5
» 014.01.36.Manual and Boot Activated Nw Config
5
» 014.01.38.Network Configuration Managers
10
» 014.01.40.Resolving Hostnames
19
» 014.01.42.The Transport Layer TCP UDP Services.
10
» 014.01.44.Understanding DHCP
5
» 014.01.46.Automatic IPv6 Network Configuration. IQs
5
» 014.01.48.Configuring Linux as Router
5
» 014.01.50.Private Networks IPv4
5
» 014.01.52.Network Address Translation. IP Masquerading
5
» 014.01.54.Routers And Linux
5
» 014.01.56.Linux Firewall Basics
5
» 014.01.58.Setting Firewall Rules
5
» 014.01.60.Firewall Strategies
10
» 014.01.62.Ethernet-IP-ARP-NDP-IQs
5
» 014.01.64.Wireless Ethernet
5
» 014.02.Network Applications and Services
11
» 014.02.12.Basics of Services
3
» 014.02.14.Introduction to Network Servers
2
» 014.02.16.Network Servers. Secure Shell
5
» 014.06.Network Protocol Telnet
38
» 014.06.12.Introduction-To-Telnet
3
» 014.06.14.General Working. Telnet
5
» 014.06.16.General-Working-Telnet
5
» 014.06.18.Network Virtual Terminal
3
» 014.06.20.More About Telnet
3
» 014.06.22.Installing Telnet on Fedora
5
» 014.06.24.Telnet Commands-Fedora
3
» 014.06.26.Using Telnet in Linux
5
» 014.06.28.Secure telnet with FirewallD. Fedora.
3
» 014.06.30.Using Telnet in Linux
2
» 014.06.DHCP. A network management protocol
26
015 Python with Eclipse on Linux
27
025.Rust Programming
1
101 Advanced Data Structures using C
18
104.Mastering Linux Network Stack
1
» 104.01.Linux Network Stack User-Space
1
105 Parallel Port Device Drivers Development
5
205 Serial Port Device Drivers Development
3
303 Linux System Programming
32
Project 22. Ethernet Network Device Driver Development
0
Query
557
Project.203 Linux System Programming. MySQL
0
Pravjot Sir Classes
161
Events at EmbLogic
2
Project 16: SPI Device Driver Development
2
Project 17: I2C Device Driver Development
0
Project 18: PCI Device Driver Development
0
Project 19: Embedded Linux on ARM Using Network TFTP
0
Project 20: CAN Bus Protocol and Driver Development
0
Project 21: USB Device Drivers Development
0
Embedded Linux
0
ARM Embedded Processor
0
Training
2
Members Area
1
Word From Admin
1