The post C Interview Questions | StudyObject appeared first on StudyObject.
]]>C questions are mostly of program type so practice these questions.
#include<stdio.h>
int main()
{
char a[]=”hello”;
char *p=”hello”;
printf(“%d—%d—“,sizeof(a),
printf(“%d—%d”,sizeof(p),
return 0;
}
Output:
6—5—4—5
Pointer always returns its size with sizeof
Sizeof operator includes “null” at the end of string
#include<stdio.h>
#include<string.h>int main() {
char A[100]=”ITTINA”, temp;
int i, j = 0;printf(“nEnter the string : %s” , A);i = 0;
j = strlen(A) – 1;while (i < j) {
temp = A[i];
A[i] = A[j];
A[j] = temp;
i++;
j–;}printf(“nafter reversal: %s” , A);}
#include<stdio.h>
#include<string.h>void reverse(char* p);int main()
{char p[]=”hello”;reverse(p);printf(“%s”,p);return 0;
}
void reverse(char* p)
{
char *start = p;
char *end = p+strlen(p)-1;
char tmp;
while(end>start)
{
tmp=*end;
*end=*start;
*start=tmp;
start++;
end–;
}
}
#include<stdio.h>char * rev(char *);
int main()
{
char A[10] = “HELLO”;
printf(“%s”,A);
char *p = rev(A);
printf(“—–>%s”,p);return 0;
}char* rev(char *p)
{
static int i=0;
static char m[10];if(*p)
{
rev(p+1);
m[i++]=*p;}return m;
}
#include<stdio.h>
int main()
{
int *p=NULL;
printf( “printing p %d”,*p);
}
NULL points to 0x00 which is protected by kernal so it does nt allow it to derefence
Output:-
Segmentation fault
#include<iostream>int main()
{char *p=”HELLOn”;printf(“%s”,p);printf(p);printf(“HELLO”);}Output:-
HELLO
HELLO
HELLO
#include<stdio.h>
int main()
{
int a= 0x12345678;
char *p=(char*)&a;
printf(“%x”,*p);
if (*p==0x78)
printf(“little endian”);
}
Output:
78little endian
atoi converts string to integer value
#include <stdio.h>
int Atoi(char *mystring)
{
int result = 0;
int i;
for ( i = 0; mystring[i] != ‘�’; ++i)
{
result = result*10 + mystring[i] – ‘0’; // ‘0’ is 48 – we need to subtract 48 from each assci to get the integer
}
return result;
}
int main()
{
char mystring[] = “194567”;
int finalvalue = Atoi(mystring);
printf (“%d “, finalvalue);
return 0;
}
Output-
194567
Always remember original atoi in std lib does nt process characters like abcd and if given alongwith integer it silently ignores it
#include <stdio.h>
#include <stdlib.h> /* atoi */
int Atoi(char *mystring)
{
int result = 0;
int i;
for ( i = 0; mystring[i] != ‘�’; ++i)
{
result = result*10 + mystring[i] – ‘0’;
}
return result;
}
int main()
{
char mystring[] = “123a”;
int finalvalue = Atoi(mystring);
printf (“%dn “, finalvalue);
int at =atoi(mystring);
printf (“%d “, at);
return 0;
}
Output:-
1279
123
#include<stdio.h>
int display();
int main()
{
int (*functionPtr)(); //declaration of function pointer
functionPtr=display;
(*functionPtr)(); //making a call to function via function pointer
}
int display()
{
printf(“Function pointer
}
Output:-
Function pointer explained
The post C Interview Questions | StudyObject appeared first on StudyObject.
]]>The post Internship at Studyobject appeared first on StudyObject.
]]>Qualification Needed:-
1.Solid understanding of algorithms, operating system. Good knowledge of html, css, php, mysql .Experience in writing high quality code.
2.Proactive with eager to learn new technologies.
3.Students in 3rd year/ final year of B.TECH/ Fresh B.Tech Pass-out from Tier- 1/Tier-2 college
4.Personal Interview will be done remotely via videocall.
5.The internship period is for 3 months.
1.Internship includes real life problem solving and building blocks for career.
2.Learn from industry experts
3.Learn more in startup culture.
4.Internship Experience Certificate
Contact – [email protected]
The post Internship at Studyobject appeared first on StudyObject.
]]>