SlideShare a Scribd company logo
1 of 4
Answer the following question about Programming in C
Q1. What is unusual about the logical operators? Explain how you can jump from one function
to another.
Answer :- Logical operators are unusual because they allow you to perform operations on
Boolean values (true or false) rather than numerical values. They are often used in conditional
statements, such as if-else statements, to control the flow of a program. You can jump from one
function to another by using the logical operator "goto" which directs the execution of a program
to a specific labeled location, however it's not recommended to use it as it makes the code less
readable and harder to maintain.
Q2. Create a structure for Date (dd, mm, yy), enter two dates in D1 and D2, write program that
print the greater date among them.
Answer :- struct Date {
int day;
int month;
int year;
};
struct Date D1, D2;
//Enter two dates in D1 and D2
scanf("%d %d %d", &D1.day, &D1.month, &D1.year);
scanf("%d %d %d", &D2.day, &D2.month, &D2.year);
//Compare two dates and print the greater date
if (D1.year > D2.year) {
printf("%d-%d-%d", D1.day, D1.month, D1.year);
} else if (D1.year == D2.year) {
if (D1.month > D2.month) {
printf("%d-%d-%d", D1.day, D1.month, D1.year);
} else if (D1.month == D2.month) {
if (D1.day > D2.day) {
printf("%d-%d-%d", D1.day, D1.month, D1.year);
} else {
printf("%d-%d-%d", D2.day, D2.month, D2.year);
}
} else {
printf("%d-%d-%d", D2.day, D2.month, D2.year);
}
} else {
printf("%d-%d-%d", D2.day, D2.month, D2.year);
}
Q3. Discuss the guidelines for drawing flowcharts and their advantages. Draw a flowchart to find
the sum of first 50 natural numbers.
Answer :- Guidelines for flowcharts include using standardized symbols, proper alignment and
spacing, and clear labeling. Their advantages include improved communication and
understanding of processes, identification of bottlenecks and inefficiencies, and ease of making
changes. Draw a flowchart for finding the sum of first 50 natural numbers:
Q4. What are functions? Create a function to find the factors of the number.
Answer :- Functions are blocks of code that perform a specific task and can be reused
throughout a program. They allow for better organization and modularity. Here's an example
function in C to find the factors of a number:
void factors(int num) {
for (int i = 1; i <= num; i++) {
if (num % i == 0) {
printf("%d ", i);
}
}
}
Q5. What is the difference between high and low level filing? Write a program to display
contents of a file on the screen.
Answer :- High-level filing refers to the organization of data based on the meaning of the data,
such as by category, subject, or customer, while low-level filing refers to the organization of data
based on the physical characteristics of the data, such as by size, color, or shape. Here's an
example program that displays contents of a file on the page.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream file;
file.open("example.txt");
string line;
while (getline(file, line))
{
cout << line << endl;
}
file.close();
return 0;
}
Q6. Discuss the concepts of Duration, Scope and Linkage to control accessibility throughout a
program.
Answer ;-Duration, scope, and linkage are the three concepts that control accessibility
throughout a program.
1. Duration refers to the lifetime of a variable or an object in the memory. It tells you how
long a variable or an object will exist in the memory.
2. Scope refers to the region of the program where a variable or an object can be
accessed. It tells you where a variable or an object can be accessed in the program.
3. Linkage refers to the association of a variable or an object with a program or module. It
tells you whether a variable or an object can be accessed by other programs or
modules.
Q7. Write a program to check whether the entered number is odd or even.
Answer :- #include <stdio.h>
int main(){
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0)
printf("%d is even", num);
else
printf("%d is odd", num);
return 0;
}
Q8. Write short notes on Pointers and Expressions involving pointers.
Answer :- Pointers are variables that hold the memory addresses of other variables. They allow
you to manipulate memory directly and can improve the performance of a program. Expressions
involving pointers include:
1. Dereferencing a pointer: accessing the value stored at the memory address held by the
pointer.
2. Assigning a pointer: assigning the memory address of a variable to a pointer.
3. Arithmetic operations on pointers: adding or subtracting an integer from a pointer, which
moves the pointer to a different memory location.
4. Comparison operations on pointers: comparing the memory addresses held by two
pointers.

More Related Content

Similar to Programming in C.docx

Frequently asked tcs technical interview questions and answers
Frequently asked tcs technical interview questions and answersFrequently asked tcs technical interview questions and answers
Frequently asked tcs technical interview questions and answersnishajj
 
SWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design ToolsSWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design Toolsghayour abbas
 
Evolutionary Multi-Goal Workflow Progress in Shade
Evolutionary  Multi-Goal Workflow Progress in ShadeEvolutionary  Multi-Goal Workflow Progress in Shade
Evolutionary Multi-Goal Workflow Progress in ShadeIRJET Journal
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming Rokonuzzaman Rony
 
Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Gurpreet singh
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++ shammi mehra
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statementsankurkhanna
 
7a Good Programming Practice.pptx
7a Good Programming Practice.pptx7a Good Programming Practice.pptx
7a Good Programming Practice.pptxDylanTilbury1
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...Rowank2
 
Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineeringsmumbahelp
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfAsst.prof M.Gokilavani
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxurvashipundir04
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEMMansi Tyagi
 

Similar to Programming in C.docx (20)

Frequently asked tcs technical interview questions and answers
Frequently asked tcs technical interview questions and answersFrequently asked tcs technical interview questions and answers
Frequently asked tcs technical interview questions and answers
 
SWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design ToolsSWE-401 - 6. Software Analysis and Design Tools
SWE-401 - 6. Software Analysis and Design Tools
 
Evolutionary Multi-Goal Workflow Progress in Shade
Evolutionary  Multi-Goal Workflow Progress in ShadeEvolutionary  Multi-Goal Workflow Progress in Shade
Evolutionary Multi-Goal Workflow Progress in Shade
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
Principal of objected oriented programming
Principal of objected oriented programming Principal of objected oriented programming
Principal of objected oriented programming
 
Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
 
Ch14
Ch14Ch14
Ch14
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
7a Good Programming Practice.pptx
7a Good Programming Practice.pptx7a Good Programming Practice.pptx
7a Good Programming Practice.pptx
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
 
Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineering
 
GE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdfGE3151 PSPP _Unit 1 notes and Question bank.pdf
GE3151 PSPP _Unit 1 notes and Question bank.pdf
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Sd Revision
Sd RevisionSd Revision
Sd Revision
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
object oriented programming part inheritance.pptx
object oriented programming part inheritance.pptxobject oriented programming part inheritance.pptx
object oriented programming part inheritance.pptx
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
Software metrics
Software metricsSoftware metrics
Software metrics
 

Recently uploaded

VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneCall girls in Ahmedabad High profile
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneCall girls in Ahmedabad High profile
 

Recently uploaded (20)

VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 

Programming in C.docx

  • 1. Answer the following question about Programming in C Q1. What is unusual about the logical operators? Explain how you can jump from one function to another. Answer :- Logical operators are unusual because they allow you to perform operations on Boolean values (true or false) rather than numerical values. They are often used in conditional statements, such as if-else statements, to control the flow of a program. You can jump from one function to another by using the logical operator "goto" which directs the execution of a program to a specific labeled location, however it's not recommended to use it as it makes the code less readable and harder to maintain. Q2. Create a structure for Date (dd, mm, yy), enter two dates in D1 and D2, write program that print the greater date among them. Answer :- struct Date { int day; int month; int year; }; struct Date D1, D2; //Enter two dates in D1 and D2 scanf("%d %d %d", &D1.day, &D1.month, &D1.year); scanf("%d %d %d", &D2.day, &D2.month, &D2.year); //Compare two dates and print the greater date if (D1.year > D2.year) { printf("%d-%d-%d", D1.day, D1.month, D1.year); } else if (D1.year == D2.year) { if (D1.month > D2.month) { printf("%d-%d-%d", D1.day, D1.month, D1.year); } else if (D1.month == D2.month) { if (D1.day > D2.day) { printf("%d-%d-%d", D1.day, D1.month, D1.year); } else { printf("%d-%d-%d", D2.day, D2.month, D2.year); } } else { printf("%d-%d-%d", D2.day, D2.month, D2.year); } } else { printf("%d-%d-%d", D2.day, D2.month, D2.year); }
  • 2. Q3. Discuss the guidelines for drawing flowcharts and their advantages. Draw a flowchart to find the sum of first 50 natural numbers. Answer :- Guidelines for flowcharts include using standardized symbols, proper alignment and spacing, and clear labeling. Their advantages include improved communication and understanding of processes, identification of bottlenecks and inefficiencies, and ease of making changes. Draw a flowchart for finding the sum of first 50 natural numbers: Q4. What are functions? Create a function to find the factors of the number. Answer :- Functions are blocks of code that perform a specific task and can be reused throughout a program. They allow for better organization and modularity. Here's an example function in C to find the factors of a number: void factors(int num) { for (int i = 1; i <= num; i++) { if (num % i == 0) { printf("%d ", i); } } } Q5. What is the difference between high and low level filing? Write a program to display contents of a file on the screen. Answer :- High-level filing refers to the organization of data based on the meaning of the data, such as by category, subject, or customer, while low-level filing refers to the organization of data based on the physical characteristics of the data, such as by size, color, or shape. Here's an example program that displays contents of a file on the page. #include <iostream> #include <fstream> using namespace std; int main() { ifstream file; file.open("example.txt"); string line;
  • 3. while (getline(file, line)) { cout << line << endl; } file.close(); return 0; } Q6. Discuss the concepts of Duration, Scope and Linkage to control accessibility throughout a program. Answer ;-Duration, scope, and linkage are the three concepts that control accessibility throughout a program. 1. Duration refers to the lifetime of a variable or an object in the memory. It tells you how long a variable or an object will exist in the memory. 2. Scope refers to the region of the program where a variable or an object can be accessed. It tells you where a variable or an object can be accessed in the program. 3. Linkage refers to the association of a variable or an object with a program or module. It tells you whether a variable or an object can be accessed by other programs or modules. Q7. Write a program to check whether the entered number is odd or even. Answer :- #include <stdio.h> int main(){ int num; printf("Enter a number: "); scanf("%d", &num); if (num % 2 == 0) printf("%d is even", num); else printf("%d is odd", num); return 0; } Q8. Write short notes on Pointers and Expressions involving pointers. Answer :- Pointers are variables that hold the memory addresses of other variables. They allow you to manipulate memory directly and can improve the performance of a program. Expressions involving pointers include: 1. Dereferencing a pointer: accessing the value stored at the memory address held by the pointer. 2. Assigning a pointer: assigning the memory address of a variable to a pointer. 3. Arithmetic operations on pointers: adding or subtracting an integer from a pointer, which moves the pointer to a different memory location.
  • 4. 4. Comparison operations on pointers: comparing the memory addresses held by two pointers.