SlideShare uma empresa Scribd logo
1 de 30
int *pi;
char *pc;
short int *psi;
printf(“ %d n”,sizeof(pi));
printf(“ %d n”,sizeof(pc));
printf(“ %d n”,sizeof(psi));
int *pi;
char *pc;
short int *psi;
printf(“ %d n”,sizeof(*pi));
printf(“ %d n”,sizeof(*pc));
printf(“ %d n”,sizeof(*psi));
int *pi = (int *)2000;
char *pc = (char *)2000;
pi++;
pc++;
printf(“ %u %u “ , pi , pc);
int x = 0x1234;
char c = x;
printf(“ %x “ , c);
const int x = 10;
1.int * const ptr1 = &x;
2.int const * ptr2 = &x;
3.const int * ptr3 = &x;
void update(int *p)
{
*p = *p + 5;
}
int main( )
{
int x = 10;
int *ptr = &x;
update(ptr);
printf(“x = %d “ , x);
}
void update(int *p)
{
p = p + 1;
}
int main( )
{
int arr[ ] = {10 , 12 , 25 , 45};
int *ptr = arr;
update(ptr);
printf(“*ptr = %d “ , *ptr);
}
void update(int *p)
{
*p = *p + 1;
}
int main( )
{
int arr[ ] = {10 , 12 , 25 , 45};
int *ptr = arr;
update(ptr);
printf(“*ptr = %d “ , *ptr);
}
void update(char *str)
{
str = “Devendra”;
}
int main( )
{
char *name = “Nimisha”;
update(name);
printf(“ %s n” , name);
}
void update(char *str)
{
str[0] = ‘H’;
}
int main( )
{
char name[ ] = “Nimisha”;
char *ptr = name;
update(ptr);
printf(“ %s n” , name);
}
void update(char *str)
{
*++str = ‘a’;
}
int main( )
{
char name[ ] = “Nimisha”;
char *ptr = name;
update(ptr);
printf(“ %s n” , name);
}
int main( )
{
char names[]
[10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”};
printf(“ %__ “ , *(names + 2) + 3);
printf(“ %__ “ , **(names + 2) + 3);
}
int main( )
{
char names[][10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”};
1. printf(“ %s “ , *(++names));
2. printf(“ %s “ , ++*(names));
3. printf(“ %c “ , ++**(names));
}
int main( )
{
char *names[10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”};
1. printf(“ %s “ , *(++names));
2. printf(“ %s “ , ++*(names));
3. printf(“ %c “ , ++**(names));
}
struct Student
{
int id;
char name[20];
};
int main( )
{
struct Student s1 = {1 , “Ayushi”};
struct Student s2 = {2 , “Ayushi”};
if(s1.name == s2.name)
printf(“Equal”);
else
printf(“Not Equal”);
}
char *names[ ] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”};
printf(“ %d “ , sizeof(names));
printf(“ %d “ , sizeof(names[0]));
char names[ ][10] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”};
printf(“ %d “ , sizeof(names));
printf(“ %d “ , sizeof(names[0]));
void display( char *names[ ])
{
printf(“Display : %d n “ , sizeof(names));
}
int main( )
{
char *names[ ] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”};
printf(“Main : %d n“ , sizeof(names));
display( names );
}
static int x = 5;
int main( )
{
int x;
printf(“x = %d n”,x);
}
static int x = 5;
int main( )
{
extern int x;
printf(“x = %d n”,x);
}
int a = 5;
int b;
static int c = 7;
static int d;
int main( )
{
}
• Mention the memory segments of
variables after compiling (.o file) and
after linking (a.out)
• What is the difference between a
and c.
• Use nm utility to view the memory
segments
$gcc –c file.c
$nm file.o
$gcc file.c
$nm ./a.out
void func( );
int x;
int main( )
{
x = 5;
func( );
printf(“x = %d “ , x);
}
int x;
void func( )
{
x = 10;
}
[sikander@localhost ~]$ gcc -c f1.c
[sikander@localhost ~]$ gcc -c f2.c
[sikander@localhost ~]$ nm f1.o
U func
00000000 T main
U printf
00000004 C x
[sikander@localhost ~]$ nm f2.o
00000000 T func
00000004 C x
[sikander@localhost ~]$ gcc f1.o f2.o
[sikander@localhost ~]$ nm a.out
080495ac B x
void func( );
int x = 5;
int main( )
{
func( );
printf(“x = %d “ , x);
}
int x = 10;
void func( )
{
x++;
}
 [sikander@localhost ~]$ gcc -c f1.c
 [sikander@localhost ~]$ gcc -c f2.c
 [sikander@localhost ~]$ nm f1.o
 00000000 D x
 [sikander@localhost ~]$ nm f2.o
 00000000 D x
 [sikander@localhost ~]$ gcc f1.o f2.o
 f2.o(.data+0x0): multiple definition of `x'
 f1.o(.data+0x0): first defined here
 collect2: ld returned 1 exit status
C C
B
C D
D
D D
Multiple Definition
d d
No Conflict, two different variables
b b
No Conflict, two different variables
d b
No Conflict, two different variables
b d
No Conflict, two different variables
b D
No Conflict, two different variables
int x ; //C
int main( )
{
printf(“Main &x= %p” , &x);
printf(“x = %d n”, x);
func( );
}
int x ; //C
void func( )
{
printf(“Func &x= %p” , &x);
printf(“x = %d n”, x);
}
int x ; //C
int main( )
{
printf(“Main &x= %p” , &x);
printf(“x = %d n”, x);
func( );
}
int x = 5 ; //D
void func( )
{
printf(“Func &x= %p” , &x);
printf(“x = %d n”, x);
}
void func( );
int x = 5; //D
int main( )
{
printf(“Main &x= %p” , &x);
printf(“x = %d n”, x);
func( );
}
int x = 10; //D
void func( )
{
printf(“Func &x= %p” , &x);
printf(“x = %d n”, x);
}
void func( );
static int x = 5; //d
int main( )
{
printf(“Main &x= %p” , &x);
printf(“x = %d n”, x);
func( );
}
int x = 10; //D
void func( )
{
printf(“Func &x= %p” , &x);
printf(“x = %d n”, x);
}
const int x = 10; //Read Only
int main( )
{
const int y = 5; //Stack
}
const int x = 10; //Read Only
int main( )
{
const int y = 5; //Stack
printf(“Enter the value for local const variable : “);
scanf(“ %d”,&y);
printf(“Local Const = %d n” , y);
printf(“Enter the value for global const variable : “);
scanf(“ %d”,&x);
printf(“Global Const = %d n”,x);
}
[sikander@localhost ~]$ ./a.out
Enter the value for local const variable : 89
Local Const = 89
Enter the value for global const variable : 6
Segmentation fault
 [sikander@localhost ~]$ nm f1.o
 00000000 t display
 0000000a T main
 00000005 T print
static void display()
{
}
void print()
{
}
int main( )
{
display( );
print( );
}

Mais conteúdo relacionado

Mais procurados

C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloadingmohamed sikander
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File Harjinder Singh
 
Double linked list
Double linked listDouble linked list
Double linked listSayantan Sur
 
Double linked list
Double linked listDouble linked list
Double linked listraviahuja11
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++Bharat Kalia
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th StudyChris Ohk
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shortingargusacademy
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structuresvinay arora
 

Mais procurados (20)

Pointer level 2
Pointer   level 2Pointer   level 2
Pointer level 2
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Double linked list
Double linked listDouble linked list
Double linked list
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
C++ file
C++ fileC++ file
C++ file
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
C++ programs
C++ programsC++ programs
C++ programs
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Vcs16
Vcs16Vcs16
Vcs16
 
C++ Programming - 14th Study
C++ Programming - 14th StudyC++ Programming - 14th Study
C++ Programming - 14th Study
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
 

Destaque

8_Diversity and antimicrobial activity of fungal endophyte communities associ...
8_Diversity and antimicrobial activity of fungal endophyte communities associ...8_Diversity and antimicrobial activity of fungal endophyte communities associ...
8_Diversity and antimicrobial activity of fungal endophyte communities associ...Aline Bruna Martins Vaz
 
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...Kevin Carter
 
6 группа игры и игрушки
6 группа игры и игрушки6 группа игры и игрушки
6 группа игры и игрушкиCnit-srstu
 
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)Canary Islands Hub
 
5 Reasons & 5 Opportunities to do business from the Canary Islands Hub
5 Reasons & 5 Opportunities to do business from the Canary Islands Hub5 Reasons & 5 Opportunities to do business from the Canary Islands Hub
5 Reasons & 5 Opportunities to do business from the Canary Islands HubCanary Islands Hub
 
305965972 aloksan-glucose-n-trombosit
305965972 aloksan-glucose-n-trombosit305965972 aloksan-glucose-n-trombosit
305965972 aloksan-glucose-n-trombositLailatul Rofiah
 
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...Warnet Raha
 
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)Adeline Dlin
 
Television trends in Tamil Satellite Channels an analysis
Television trends in Tamil Satellite Channels an analysis Television trends in Tamil Satellite Channels an analysis
Television trends in Tamil Satellite Channels an analysis A.Sivakumar @mediashiva
 
Ppt on case study of near misses in singhania textile mills
Ppt on case study of near misses in singhania textile millsPpt on case study of near misses in singhania textile mills
Ppt on case study of near misses in singhania textile millsRajib jena
 
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasi
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan KomplikasiKonsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasi
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasipjj_kemenkes
 
Diversity, Inclusion and Innovation Strategic Leadership Assessment Tool
Diversity, Inclusion and Innovation Strategic Leadership Assessment ToolDiversity, Inclusion and Innovation Strategic Leadership Assessment Tool
Diversity, Inclusion and Innovation Strategic Leadership Assessment ToolKevin Carter
 

Destaque (20)

8_Diversity and antimicrobial activity of fungal endophyte communities associ...
8_Diversity and antimicrobial activity of fungal endophyte communities associ...8_Diversity and antimicrobial activity of fungal endophyte communities associ...
8_Diversity and antimicrobial activity of fungal endophyte communities associ...
 
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...
Kevin A Carter Disruptive Inclusion (Diversity Inclusion Innovation) Presenta...
 
Kti siti sariandi
Kti siti sariandiKti siti sariandi
Kti siti sariandi
 
6 группа игры и игрушки
6 группа игры и игрушки6 группа игры и игрушки
6 группа игры и игрушки
 
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)
Fiscal Regime in the Canary Islands by E&Y (Canary Islands Hub)
 
5 Reasons & 5 Opportunities to do business from the Canary Islands Hub
5 Reasons & 5 Opportunities to do business from the Canary Islands Hub5 Reasons & 5 Opportunities to do business from the Canary Islands Hub
5 Reasons & 5 Opportunities to do business from the Canary Islands Hub
 
спрощення в групах приголосних
спрощення в групах приголоснихспрощення в групах приголосних
спрощення в групах приголосних
 
305965972 aloksan-glucose-n-trombosit
305965972 aloksan-glucose-n-trombosit305965972 aloksan-glucose-n-trombosit
305965972 aloksan-glucose-n-trombosit
 
Kel 5
Kel 5Kel 5
Kel 5
 
88888888 88888888
88888888 8888888888888888 88888888
88888888 88888888
 
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...
MANAJEMEN DAN PENDOKUMENTASIAN ASUHAN KEBIDANAN PADA BAYI NY. ”I” DENGAN BAYI...
 
Kti ida bagus
Kti ida bagusKti ida bagus
Kti ida bagus
 
Infeksi Puerperalis
Infeksi PuerperalisInfeksi Puerperalis
Infeksi Puerperalis
 
Protocols
ProtocolsProtocols
Protocols
 
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)
CephaloPelvicDisporportion (pembimbing : dr. Arie Widiyasa, spOG)
 
Television trends in Tamil Satellite Channels an analysis
Television trends in Tamil Satellite Channels an analysis Television trends in Tamil Satellite Channels an analysis
Television trends in Tamil Satellite Channels an analysis
 
Ppt on case study of near misses in singhania textile mills
Ppt on case study of near misses in singhania textile millsPpt on case study of near misses in singhania textile mills
Ppt on case study of near misses in singhania textile mills
 
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasi
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan KomplikasiKonsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasi
Konsep dan Asuhan Keperawatan Ibu Hamil Normal dan Komplikasi
 
Diversity, Inclusion and Innovation Strategic Leadership Assessment Tool
Diversity, Inclusion and Innovation Strategic Leadership Assessment ToolDiversity, Inclusion and Innovation Strategic Leadership Assessment Tool
Diversity, Inclusion and Innovation Strategic Leadership Assessment Tool
 
TOILET AND SUTURE
TOILET AND SUTURETOILET AND SUTURE
TOILET AND SUTURE
 

Semelhante a C questions (20)

Pointer basics
Pointer basicsPointer basics
Pointer basics
 
C basics
C basicsC basics
C basics
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
lets play with "c"..!!! :):)
lets play with "c"..!!! :):)lets play with "c"..!!! :):)
lets play with "c"..!!! :):)
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Tu1
Tu1Tu1
Tu1
 
(Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++ (Meta 5) ejemplo vectores dev c++
(Meta 5) ejemplo vectores dev c++
 
(Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++ (Meta 5) ejemplo vectores 2 dev c++
(Meta 5) ejemplo vectores 2 dev c++
 
Functions in c
Functions in cFunctions in c
Functions in c
 
C programming function
C  programming functionC  programming function
C programming function
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C programms
C programmsC programms
C programms
 
7 functions
7  functions7  functions
7 functions
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
5th Sem SS lab progs
5th Sem SS lab progs5th Sem SS lab progs
5th Sem SS lab progs
 

Mais de mohamed sikander

Mais de mohamed sikander (7)

C++ 11 range-based for loop
C++ 11   range-based for loopC++ 11   range-based for loop
C++ 11 range-based for loop
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance and polymorphism
Inheritance and polymorphismInheritance and polymorphism
Inheritance and polymorphism
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Static and const members
Static and const membersStatic and const members
Static and const members
 

Último

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Último (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

C questions

  • 1.
  • 2. int *pi; char *pc; short int *psi; printf(“ %d n”,sizeof(pi)); printf(“ %d n”,sizeof(pc)); printf(“ %d n”,sizeof(psi)); int *pi; char *pc; short int *psi; printf(“ %d n”,sizeof(*pi)); printf(“ %d n”,sizeof(*pc)); printf(“ %d n”,sizeof(*psi));
  • 3. int *pi = (int *)2000; char *pc = (char *)2000; pi++; pc++; printf(“ %u %u “ , pi , pc);
  • 4. int x = 0x1234; char c = x; printf(“ %x “ , c);
  • 5. const int x = 10; 1.int * const ptr1 = &x; 2.int const * ptr2 = &x; 3.const int * ptr3 = &x;
  • 6. void update(int *p) { *p = *p + 5; } int main( ) { int x = 10; int *ptr = &x; update(ptr); printf(“x = %d “ , x); }
  • 7. void update(int *p) { p = p + 1; } int main( ) { int arr[ ] = {10 , 12 , 25 , 45}; int *ptr = arr; update(ptr); printf(“*ptr = %d “ , *ptr); }
  • 8. void update(int *p) { *p = *p + 1; } int main( ) { int arr[ ] = {10 , 12 , 25 , 45}; int *ptr = arr; update(ptr); printf(“*ptr = %d “ , *ptr); }
  • 9. void update(char *str) { str = “Devendra”; } int main( ) { char *name = “Nimisha”; update(name); printf(“ %s n” , name); }
  • 10. void update(char *str) { str[0] = ‘H’; } int main( ) { char name[ ] = “Nimisha”; char *ptr = name; update(ptr); printf(“ %s n” , name); }
  • 11. void update(char *str) { *++str = ‘a’; } int main( ) { char name[ ] = “Nimisha”; char *ptr = name; update(ptr); printf(“ %s n” , name); }
  • 12. int main( ) { char names[] [10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”}; printf(“ %__ “ , *(names + 2) + 3); printf(“ %__ “ , **(names + 2) + 3); }
  • 13. int main( ) { char names[][10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”}; 1. printf(“ %s “ , *(++names)); 2. printf(“ %s “ , ++*(names)); 3. printf(“ %c “ , ++**(names)); }
  • 14. int main( ) { char *names[10]={“OBAMA”,”PUTIN”,”MODI”,”CAMEROON”}; 1. printf(“ %s “ , *(++names)); 2. printf(“ %s “ , ++*(names)); 3. printf(“ %c “ , ++**(names)); }
  • 15. struct Student { int id; char name[20]; }; int main( ) { struct Student s1 = {1 , “Ayushi”}; struct Student s2 = {2 , “Ayushi”}; if(s1.name == s2.name) printf(“Equal”); else printf(“Not Equal”); }
  • 16. char *names[ ] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”}; printf(“ %d “ , sizeof(names)); printf(“ %d “ , sizeof(names[0])); char names[ ][10] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”}; printf(“ %d “ , sizeof(names)); printf(“ %d “ , sizeof(names[0]));
  • 17. void display( char *names[ ]) { printf(“Display : %d n “ , sizeof(names)); } int main( ) { char *names[ ] = {“Nimisha”,”Devender”,”Vikram”,”Balwant”}; printf(“Main : %d n“ , sizeof(names)); display( names ); }
  • 18. static int x = 5; int main( ) { int x; printf(“x = %d n”,x); }
  • 19. static int x = 5; int main( ) { extern int x; printf(“x = %d n”,x); }
  • 20. int a = 5; int b; static int c = 7; static int d; int main( ) { } • Mention the memory segments of variables after compiling (.o file) and after linking (a.out) • What is the difference between a and c. • Use nm utility to view the memory segments $gcc –c file.c $nm file.o $gcc file.c $nm ./a.out
  • 21. void func( ); int x; int main( ) { x = 5; func( ); printf(“x = %d “ , x); } int x; void func( ) { x = 10; }
  • 22. [sikander@localhost ~]$ gcc -c f1.c [sikander@localhost ~]$ gcc -c f2.c [sikander@localhost ~]$ nm f1.o U func 00000000 T main U printf 00000004 C x [sikander@localhost ~]$ nm f2.o 00000000 T func 00000004 C x [sikander@localhost ~]$ gcc f1.o f2.o [sikander@localhost ~]$ nm a.out 080495ac B x
  • 23. void func( ); int x = 5; int main( ) { func( ); printf(“x = %d “ , x); } int x = 10; void func( ) { x++; }
  • 24.  [sikander@localhost ~]$ gcc -c f1.c  [sikander@localhost ~]$ gcc -c f2.c  [sikander@localhost ~]$ nm f1.o  00000000 D x  [sikander@localhost ~]$ nm f2.o  00000000 D x  [sikander@localhost ~]$ gcc f1.o f2.o  f2.o(.data+0x0): multiple definition of `x'  f1.o(.data+0x0): first defined here  collect2: ld returned 1 exit status
  • 25. C C B C D D D D Multiple Definition d d No Conflict, two different variables b b No Conflict, two different variables d b No Conflict, two different variables b d No Conflict, two different variables b D No Conflict, two different variables
  • 26. int x ; //C int main( ) { printf(“Main &x= %p” , &x); printf(“x = %d n”, x); func( ); } int x ; //C void func( ) { printf(“Func &x= %p” , &x); printf(“x = %d n”, x); } int x ; //C int main( ) { printf(“Main &x= %p” , &x); printf(“x = %d n”, x); func( ); } int x = 5 ; //D void func( ) { printf(“Func &x= %p” , &x); printf(“x = %d n”, x); }
  • 27. void func( ); int x = 5; //D int main( ) { printf(“Main &x= %p” , &x); printf(“x = %d n”, x); func( ); } int x = 10; //D void func( ) { printf(“Func &x= %p” , &x); printf(“x = %d n”, x); } void func( ); static int x = 5; //d int main( ) { printf(“Main &x= %p” , &x); printf(“x = %d n”, x); func( ); } int x = 10; //D void func( ) { printf(“Func &x= %p” , &x); printf(“x = %d n”, x); }
  • 28. const int x = 10; //Read Only int main( ) { const int y = 5; //Stack }
  • 29. const int x = 10; //Read Only int main( ) { const int y = 5; //Stack printf(“Enter the value for local const variable : “); scanf(“ %d”,&y); printf(“Local Const = %d n” , y); printf(“Enter the value for global const variable : “); scanf(“ %d”,&x); printf(“Global Const = %d n”,x); } [sikander@localhost ~]$ ./a.out Enter the value for local const variable : 89 Local Const = 89 Enter the value for global const variable : 6 Segmentation fault
  • 30.  [sikander@localhost ~]$ nm f1.o  00000000 t display  0000000a T main  00000005 T print static void display() { } void print() { } int main( ) { display( ); print( ); }