Firstly,All the very best to everyone.!
As for the pattern
There will be 10 MCQ questions,5 Debugging questions,2 coding challenges.
All of these will cover concepts of C programming only.
MCQ will be really tricky, carefully read the question before answering.
1 Debugging is usually found to be really tricky,save it for the last as they weigh only 2 marks.
Focus on the Coding challenges once you have finished the MCQ's.
As of the coding problems,one of them will be small and easy ,attempt to finish it off first and the go to the longer(usually harder) problem.
Go through previous practice problems,they should cover most of the concepts taught.
Additionally practice pointer ,tructure implementation and string manipulation.
For additional practice try :C-PROGRAMS
Do the 2,3,4,5 Chapters and 2D arrays sections
This comment has been removed by the author.
ReplyDeleteCan you correct me regarding the 5th solution of PP2?
ReplyDelete#include
void main()
{
int n,i,j=0,k=0;
scanf("%d",&n);
int a[n][5],b[n][5];
struct comp
{
char ip[20];
char name[20];
}c[n];
for(i=0;i<n;i++)
{
scanf("%s",c[i].ip);
scanf("%s",c[i].name);
}
for(i=0;i<n;i++)
{
k=0;
j=0;
while(c[i].ip[j]!=".")
{
a[i][k]=(int)c[i].ip[j];
j++;
k++;
}
j=j+1;
k=0;
while(c[i].ip[j]!=".")
{
b[i][k]=(int)c[i].ip[j];
j++;
k++;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(i!=j)
if((a[i]==a[j]) && (b[i]==b[j]))
printf("Machines %s and %s are on the same local network",c[i].name,c[j].name);
}
}
Yes skillrack is not accepting any solution for the 5th problem.
ReplyDeleteI am still trying to figure a way to run it.
As for your code:
1.Excellent work using the concept of struct(though a simple 2d array would have sufficed).
2.It is better to compare the first two segments of the ip as a string rather than taking it as an integer array and comparing each element.Will make the code crisp and clear.
#include
ReplyDelete#include
void main()
{
int n,i,j,k,ccc=0,cc=0;
scanf("%d",&n);
struct comp
{
char ip[20];
char name[20];
}c[n];
for(i=0;i<n;i++)
{
scanf("%s",c[i].ip);
scanf("%s",c[i].name);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i!=j)
{
for(k=0;k!=".";k++)
{
if(strcmp(c[i].ip[k],c[j].ip[k])==0)
ccc++;
}
if(ccc==(k+1))
{
cc=ccc+1;
for(k=(ccc+1);k!=".";k++)
{
if(strcmp(c[i].ip[k],c[j].ip[k])==0)
cc++;
}
}
}
if(cc==k)
printf("Machines %s and %s are on the same local network",c[i].name,c[j].name);
}
}
}
Please check out this attempt. Here I had done the string comparing thing but it showed an error saying that i was comparing a pointer to an integer. So...
The for loop condition is wrong i think...
Delete"for(k=0;k!='.';k++)"
you cannot check k!='.' k is an int it will never be a char '.' .Rather check for the char in the ip.(c[i(or j)].ip[k]!=0)
Please refer to my solution that i have posted in case you are not clear. I have made a new post for this problem.
Yeah correct. Thanks a lot.
DeleteWelcome! Happy to help!
DeleteWelcome! Happy to help!
Deletewishing you the same karthick
ReplyDeleteBut one thing... when will the c++ section starts.. ??(OOP )
ReplyDeleteAll classes will mostly start with c++ after this assessment,if they haven't already. The transformation will initially involve changes in header files and basic input/output.
Deleteboss can i know the questions asked in the assesment
ReplyDelete