2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
Creative operations teams expect increased AI use in 2024. Currently, over half of tasks are not AI-enabled, but this is expected to decrease in the coming year. ChatGPT is the most popular AI tool currently. Business leaders are more actively exploring AI benefits than individual contributors. Most respondents do not believe AI will impact workforce size in 2024. However, some inhibitions still exist around AI accuracy and lack of understanding. Creatives primarily want to use AI to save time on mundane tasks and boost productivity.
Organizational culture includes values, norms, systems, symbols, language, assumptions, beliefs, and habits that influence employee behaviors and how people interpret those behaviors. It is important because culture can help or hinder a company's success. Some key aspects of Netflix's culture that help it achieve results include hiring smartly so every position has stars, focusing on attitude over just aptitude, and having a strict policy against peacocks, whiners, and jerks.
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
PepsiCo provided a safe harbor statement noting that any forward-looking statements are based on currently available information and are subject to risks and uncertainties. It also provided information on non-GAAP measures and directing readers to its website for disclosure and reconciliation. The document then discussed PepsiCo's business overview, including that it is a global beverage and convenient food company with iconic brands, $91 billion in net revenue in 2023, and nearly $14 billion in core operating profit. It operates through a divisional structure with a focus on local consumers.
Content Methodology: A Best Practices Report (Webinar)contently
This document provides an overview of content methodology best practices. It defines content methodology as establishing objectives, KPIs, and a culture of continuous learning and iteration. An effective methodology focuses on connecting with audiences, creating optimal content, and optimizing processes. It also discusses why a methodology is needed due to the competitive landscape, proliferation of channels, and opportunities for improvement. Components of an effective methodology include defining objectives and KPIs, audience analysis, identifying opportunities, and evaluating resources. The document concludes with recommendations around creating a content plan, testing and optimizing content over 90 days.
How to Prepare For a Successful Job Search for 2024Albert Qian
The document provides guidance on preparing a job search for 2024. It discusses the state of the job market, focusing on growth in AI and healthcare but also continued layoffs. It recommends figuring out what you want to do by researching interests and skills, then conducting informational interviews. The job search should involve building a personal brand on LinkedIn, actively applying to jobs, tailoring resumes and interviews, maintaining job hunting as a habit, and continuing self-improvement. Once hired, the document advises setting new goals and keeping skills and networking active in case of future opportunities.
A report by thenetworkone and Kurio.
The contributing experts and agencies are (in an alphabetical order): Sylwia Rytel, Social Media Supervisor, 180heartbeats + JUNG v MATT (PL), Sharlene Jenner, Vice President - Director of Engagement Strategy, Abelson Taylor (USA), Alex Casanovas, Digital Director, Atrevia (ES), Dora Beilin, Senior Social Strategist, Barrett Hoffher (USA), Min Seo, Campaign Director, Brand New Agency (KR), Deshé M. Gully, Associate Strategist, Day One Agency (USA), Francesca Trevisan, Strategist, Different (IT), Trevor Crossman, CX and Digital Transformation Director; Olivia Hussey, Strategic Planner; Simi Srinarula, Social Media Manager, The Hallway (AUS), James Hebbert, Managing Director, Hylink (CN / UK), Mundy Álvarez, Planning Director; Pedro Rojas, Social Media Manager; Pancho González, CCO, Inbrax (CH), Oana Oprea, Head of Digital Planning, Jam Session Agency (RO), Amy Bottrill, Social Account Director, Launch (UK), Gaby Arriaga, Founder, Leonardo1452 (MX), Shantesh S Row, Creative Director, Liwa (UAE), Rajesh Mehta, Chief Strategy Officer; Dhruv Gaur, Digital Planning Lead; Leonie Mergulhao, Account Supervisor - Social Media & PR, Medulla (IN), Aurelija Plioplytė, Head of Digital & Social, Not Perfect (LI), Daiana Khaidargaliyeva, Account Manager, Osaka Labs (UK / USA), Stefanie Söhnchen, Vice President Digital, PIABO Communications (DE), Elisabeth Winiartati, Managing Consultant, Head of Global Integrated Communications; Lydia Aprina, Account Manager, Integrated Marketing and Communications; Nita Prabowo, Account Manager, Integrated Marketing and Communications; Okhi, Web Developer, PNTR Group (ID), Kei Obusan, Insights Director; Daffi Ranandi, Insights Manager, Radarr (SG), Gautam Reghunath, Co-founder & CEO, Talented (IN), Donagh Humphreys, Head of Social and Digital Innovation, THINKHOUSE (IRE), Sarah Yim, Strategy Director, Zulu Alpha Kilo (CA).
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
The search marketing landscape is evolving rapidly with new technologies, and professionals, like you, rely on innovative paid search strategies to meet changing demands.
It’s important that you’re ready to implement new strategies in 2024.
Check this out and learn the top trends in paid search advertising that are expected to gain traction, so you can drive higher ROI more efficiently in 2024.
You’ll learn:
- The latest trends in AI and automation, and what this means for an evolving paid search ecosystem.
- New developments in privacy and data regulation.
- Emerging ad formats that are expected to make an impact next year.
Watch Sreekant Lanka from iQuanti and Irina Klein from OneMain Financial as they dive into the future of paid search and explore the trends, strategies, and technologies that will shape the search marketing landscape.
If you’re looking to assess your paid search strategy and design an industry-aligned plan for 2024, then this webinar is for you.
5 Public speaking tips from TED - Visualized summarySpeakerHub
From their humble beginnings in 1984, TED has grown into the world’s most powerful amplifier for speakers and thought-leaders to share their ideas. They have over 2,400 filmed talks (not including the 30,000+ TEDx videos) freely available online, and have hosted over 17,500 events around the world.
With over one billion views in a year, it’s no wonder that so many speakers are looking to TED for ideas on how to share their message more effectively.
The article “5 Public-Speaking Tips TED Gives Its Speakers”, by Carmine Gallo for Forbes, gives speakers five practical ways to connect with their audience, and effectively share their ideas on stage.
Whether you are gearing up to get on a TED stage yourself, or just want to master the skills that so many of their speakers possess, these tips and quotes from Chris Anderson, the TED Talks Curator, will encourage you to make the most impactful impression on your audience.
See the full article and more summaries like this on SpeakerHub here: https://speakerhub.com/blog/5-presentation-tips-ted-gives-its-speakers
See the original article on Forbes here:
http://www.forbes.com/forbes/welcome/?toURL=http://www.forbes.com/sites/carminegallo/2016/05/06/5-public-speaking-tips-ted-gives-its-speakers/&refURL=&referrer=#5c07a8221d9b
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
Everyone is in agreement that ChatGPT (and other generative AI tools) will shape the future of work. Yet there is little consensus on exactly how, when, and to what extent this technology will change our world.
Businesses that extract maximum value from ChatGPT will use it as a collaborative tool for everything from brainstorming to technical maintenance.
For individuals, now is the time to pinpoint the skills the future professional will need to thrive in the AI age.
Check out this presentation to understand what ChatGPT is, how it will shape the future of work, and how you can prepare to take advantage.
The document provides career advice for getting into the tech field, including:
- Doing projects and internships in college to build a portfolio.
- Learning about different roles and technologies through industry research.
- Contributing to open source projects to build experience and network.
- Developing a personal brand through a website and social media presence.
- Networking through events, communities, and finding a mentor.
- Practicing interviews through mock interviews and whiteboarding coding questions.
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
1. Core updates from Google periodically change how its algorithms assess and rank websites and pages. This can impact rankings through shifts in user intent, site quality issues being caught up to, world events influencing queries, and overhauls to search like the E-A-T framework.
2. There are many possible user intents beyond just transactional, navigational and informational. Identifying intent shifts is important during core updates. Sites may need to optimize for new intents through different content types and sections.
3. Responding effectively to core updates requires analyzing "before and after" data to understand changes, identifying new intents or page types, and ensuring content matches appropriate intents across video, images, knowledge graphs and more.
A brief introduction to DataScience with explaining of the concepts, algorithms, machine learning, supervised and unsupervised learning, clustering, statistics, data preprocessing, real-world applications etc.
It's part of a Data Science Corner Campaign where I will be discussing the fundamentals of DataScience, AIML, Statistics etc.
Time Management & Productivity - Best PracticesVit Horky
Here's my presentation on by proven best practices how to manage your work time effectively and how to improve your productivity. It includes practical tips and how to use tools such as Slack, Google Apps, Hubspot, Google Calendar, Gmail and others.
The six step guide to practical project managementMindGenius
The six step guide to practical project management
If you think managing projects is too difficult, think again.
We’ve stripped back project management processes to the
basics – to make it quicker and easier, without sacrificing
the vital ingredients for success.
“If you’re looking for some real-world guidance, then The Six Step Guide to Practical Project Management will help.”
Dr Andrew Makar, Tactical Project Management
2024 State of Marketing Report – by HubspotMarius Sescu
https://www.hubspot.com/state-of-marketing
· Scaling relationships and proving ROI
· Social media is the place for search, sales, and service
· Authentic influencer partnerships fuel brand growth
· The strongest connections happen via call, click, chat, and camera.
· Time saved with AI leads to more creative work
· Seeking: A single source of truth
· TLDR; Get on social, try AI, and align your systems.
· More human marketing, powered by robots
ChatGPT is a revolutionary addition to the world since its introduction in 2022. A big shift in the sector of information gathering and processing happened because of this chatbot. What is the story of ChatGPT? How is the bot responding to prompts and generating contents? Swipe through these slides prepared by Expeed Software, a web development company regarding the development and technical intricacies of ChatGPT!
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
The realm of product design is a constantly changing environment where technology and style intersect. Every year introduces fresh challenges and exciting trends that mold the future of this captivating art form. In this piece, we delve into the significant trends set to influence the look and functionality of product design in the year 2024.
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
Mental health has been in the news quite a bit lately. Dozens of U.S. states are currently suing Meta for contributing to the youth mental health crisis by inserting addictive features into their products, while the U.S. Surgeon General is touring the nation to bring awareness to the growing epidemic of loneliness and isolation. The country has endured periods of low national morale, such as in the 1970s when high inflation and the energy crisis worsened public sentiment following the Vietnam War. The current mood, however, feels different. Gallup recently reported that national mental health is at an all-time low, with few bright spots to lift spirits.
To better understand how Americans are feeling and their attitudes towards mental health in general, ThinkNow conducted a nationally representative quantitative survey of 1,500 respondents and found some interesting differences among ethnic, age and gender groups.
Technology
For example, 52% agree that technology and social media have a negative impact on mental health, but when broken out by race, 61% of Whites felt technology had a negative effect, and only 48% of Hispanics thought it did.
While technology has helped us keep in touch with friends and family in faraway places, it appears to have degraded our ability to connect in person. Staying connected online is a double-edged sword since the same news feed that brings us pictures of the grandkids and fluffy kittens also feeds us news about the wars in Israel and Ukraine, the dysfunction in Washington, the latest mass shooting and the climate crisis.
Hispanics may have a built-in defense against the isolation technology breeds, owing to their large, multigenerational households, strong social support systems, and tendency to use social media to stay connected with relatives abroad.
Age and Gender
When asked how individuals rate their mental health, men rate it higher than women by 11 percentage points, and Baby Boomers rank it highest at 83%, saying it’s good or excellent vs. 57% of Gen Z saying the same.
Gen Z spends the most amount of time on social media, so the notion that social media negatively affects mental health appears to be correlated. Unfortunately, Gen Z is also the generation that’s least comfortable discussing mental health concerns with healthcare professionals. Only 40% of them state they’re comfortable discussing their issues with a professional compared to 60% of Millennials and 65% of Boomers.
Race Affects Attitudes
As seen in previous research conducted by ThinkNow, Asian Americans lag other groups when it comes to awareness of mental health issues. Twenty-four percent of Asian Americans believe that having a mental health issue is a sign of weakness compared to the 16% average for all groups. Asians are also considerably less likely to be aware of mental health services in their communities (42% vs. 55%) and most likely to seek out information on social media (51% vs. 35%).
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
Creative operations teams expect increased AI use in 2024. Currently, over half of tasks are not AI-enabled, but this is expected to decrease in the coming year. ChatGPT is the most popular AI tool currently. Business leaders are more actively exploring AI benefits than individual contributors. Most respondents do not believe AI will impact workforce size in 2024. However, some inhibitions still exist around AI accuracy and lack of understanding. Creatives primarily want to use AI to save time on mundane tasks and boost productivity.
Organizational culture includes values, norms, systems, symbols, language, assumptions, beliefs, and habits that influence employee behaviors and how people interpret those behaviors. It is important because culture can help or hinder a company's success. Some key aspects of Netflix's culture that help it achieve results include hiring smartly so every position has stars, focusing on attitude over just aptitude, and having a strict policy against peacocks, whiners, and jerks.
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
PepsiCo provided a safe harbor statement noting that any forward-looking statements are based on currently available information and are subject to risks and uncertainties. It also provided information on non-GAAP measures and directing readers to its website for disclosure and reconciliation. The document then discussed PepsiCo's business overview, including that it is a global beverage and convenient food company with iconic brands, $91 billion in net revenue in 2023, and nearly $14 billion in core operating profit. It operates through a divisional structure with a focus on local consumers.
Content Methodology: A Best Practices Report (Webinar)contently
This document provides an overview of content methodology best practices. It defines content methodology as establishing objectives, KPIs, and a culture of continuous learning and iteration. An effective methodology focuses on connecting with audiences, creating optimal content, and optimizing processes. It also discusses why a methodology is needed due to the competitive landscape, proliferation of channels, and opportunities for improvement. Components of an effective methodology include defining objectives and KPIs, audience analysis, identifying opportunities, and evaluating resources. The document concludes with recommendations around creating a content plan, testing and optimizing content over 90 days.
How to Prepare For a Successful Job Search for 2024Albert Qian
The document provides guidance on preparing a job search for 2024. It discusses the state of the job market, focusing on growth in AI and healthcare but also continued layoffs. It recommends figuring out what you want to do by researching interests and skills, then conducting informational interviews. The job search should involve building a personal brand on LinkedIn, actively applying to jobs, tailoring resumes and interviews, maintaining job hunting as a habit, and continuing self-improvement. Once hired, the document advises setting new goals and keeping skills and networking active in case of future opportunities.
A report by thenetworkone and Kurio.
The contributing experts and agencies are (in an alphabetical order): Sylwia Rytel, Social Media Supervisor, 180heartbeats + JUNG v MATT (PL), Sharlene Jenner, Vice President - Director of Engagement Strategy, Abelson Taylor (USA), Alex Casanovas, Digital Director, Atrevia (ES), Dora Beilin, Senior Social Strategist, Barrett Hoffher (USA), Min Seo, Campaign Director, Brand New Agency (KR), Deshé M. Gully, Associate Strategist, Day One Agency (USA), Francesca Trevisan, Strategist, Different (IT), Trevor Crossman, CX and Digital Transformation Director; Olivia Hussey, Strategic Planner; Simi Srinarula, Social Media Manager, The Hallway (AUS), James Hebbert, Managing Director, Hylink (CN / UK), Mundy Álvarez, Planning Director; Pedro Rojas, Social Media Manager; Pancho González, CCO, Inbrax (CH), Oana Oprea, Head of Digital Planning, Jam Session Agency (RO), Amy Bottrill, Social Account Director, Launch (UK), Gaby Arriaga, Founder, Leonardo1452 (MX), Shantesh S Row, Creative Director, Liwa (UAE), Rajesh Mehta, Chief Strategy Officer; Dhruv Gaur, Digital Planning Lead; Leonie Mergulhao, Account Supervisor - Social Media & PR, Medulla (IN), Aurelija Plioplytė, Head of Digital & Social, Not Perfect (LI), Daiana Khaidargaliyeva, Account Manager, Osaka Labs (UK / USA), Stefanie Söhnchen, Vice President Digital, PIABO Communications (DE), Elisabeth Winiartati, Managing Consultant, Head of Global Integrated Communications; Lydia Aprina, Account Manager, Integrated Marketing and Communications; Nita Prabowo, Account Manager, Integrated Marketing and Communications; Okhi, Web Developer, PNTR Group (ID), Kei Obusan, Insights Director; Daffi Ranandi, Insights Manager, Radarr (SG), Gautam Reghunath, Co-founder & CEO, Talented (IN), Donagh Humphreys, Head of Social and Digital Innovation, THINKHOUSE (IRE), Sarah Yim, Strategy Director, Zulu Alpha Kilo (CA).
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
The search marketing landscape is evolving rapidly with new technologies, and professionals, like you, rely on innovative paid search strategies to meet changing demands.
It’s important that you’re ready to implement new strategies in 2024.
Check this out and learn the top trends in paid search advertising that are expected to gain traction, so you can drive higher ROI more efficiently in 2024.
You’ll learn:
- The latest trends in AI and automation, and what this means for an evolving paid search ecosystem.
- New developments in privacy and data regulation.
- Emerging ad formats that are expected to make an impact next year.
Watch Sreekant Lanka from iQuanti and Irina Klein from OneMain Financial as they dive into the future of paid search and explore the trends, strategies, and technologies that will shape the search marketing landscape.
If you’re looking to assess your paid search strategy and design an industry-aligned plan for 2024, then this webinar is for you.
5 Public speaking tips from TED - Visualized summarySpeakerHub
From their humble beginnings in 1984, TED has grown into the world’s most powerful amplifier for speakers and thought-leaders to share their ideas. They have over 2,400 filmed talks (not including the 30,000+ TEDx videos) freely available online, and have hosted over 17,500 events around the world.
With over one billion views in a year, it’s no wonder that so many speakers are looking to TED for ideas on how to share their message more effectively.
The article “5 Public-Speaking Tips TED Gives Its Speakers”, by Carmine Gallo for Forbes, gives speakers five practical ways to connect with their audience, and effectively share their ideas on stage.
Whether you are gearing up to get on a TED stage yourself, or just want to master the skills that so many of their speakers possess, these tips and quotes from Chris Anderson, the TED Talks Curator, will encourage you to make the most impactful impression on your audience.
See the full article and more summaries like this on SpeakerHub here: https://speakerhub.com/blog/5-presentation-tips-ted-gives-its-speakers
See the original article on Forbes here:
http://www.forbes.com/forbes/welcome/?toURL=http://www.forbes.com/sites/carminegallo/2016/05/06/5-public-speaking-tips-ted-gives-its-speakers/&refURL=&referrer=#5c07a8221d9b
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
Everyone is in agreement that ChatGPT (and other generative AI tools) will shape the future of work. Yet there is little consensus on exactly how, when, and to what extent this technology will change our world.
Businesses that extract maximum value from ChatGPT will use it as a collaborative tool for everything from brainstorming to technical maintenance.
For individuals, now is the time to pinpoint the skills the future professional will need to thrive in the AI age.
Check out this presentation to understand what ChatGPT is, how it will shape the future of work, and how you can prepare to take advantage.
The document provides career advice for getting into the tech field, including:
- Doing projects and internships in college to build a portfolio.
- Learning about different roles and technologies through industry research.
- Contributing to open source projects to build experience and network.
- Developing a personal brand through a website and social media presence.
- Networking through events, communities, and finding a mentor.
- Practicing interviews through mock interviews and whiteboarding coding questions.
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
1. Core updates from Google periodically change how its algorithms assess and rank websites and pages. This can impact rankings through shifts in user intent, site quality issues being caught up to, world events influencing queries, and overhauls to search like the E-A-T framework.
2. There are many possible user intents beyond just transactional, navigational and informational. Identifying intent shifts is important during core updates. Sites may need to optimize for new intents through different content types and sections.
3. Responding effectively to core updates requires analyzing "before and after" data to understand changes, identifying new intents or page types, and ensuring content matches appropriate intents across video, images, knowledge graphs and more.
A brief introduction to DataScience with explaining of the concepts, algorithms, machine learning, supervised and unsupervised learning, clustering, statistics, data preprocessing, real-world applications etc.
It's part of a Data Science Corner Campaign where I will be discussing the fundamentals of DataScience, AIML, Statistics etc.
Time Management & Productivity - Best PracticesVit Horky
Here's my presentation on by proven best practices how to manage your work time effectively and how to improve your productivity. It includes practical tips and how to use tools such as Slack, Google Apps, Hubspot, Google Calendar, Gmail and others.
The six step guide to practical project managementMindGenius
The six step guide to practical project management
If you think managing projects is too difficult, think again.
We’ve stripped back project management processes to the
basics – to make it quicker and easier, without sacrificing
the vital ingredients for success.
“If you’re looking for some real-world guidance, then The Six Step Guide to Practical Project Management will help.”
Dr Andrew Makar, Tactical Project Management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
NedrLBau-ZEHw2e5xL2ax-qd6U0egpTP (2).pptx
1. O’ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR
VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT
TEXNOLOGIYALARI UNIVERSITETI QARSHI FILIALI
Telekommunikatsion texnalogiyalar va kasbiy ta’lim fakulteti TT- 13-23 guruh talabasi
To'rayev Husanning Dasturlash fanidan tayyorlagan 1-Semestr uchun
5-Mustaqil ishi
Qabul qildi: Zoxidov J.B.
Bajardi: To'rayev Husan
2023
2. Chiziqli jarayonlarni tashkil etish (Algoritm va dastur).
Sinflarni yaratishda operatorlarni qayta yuklash mexanizmidan unumli foydalanish.
Shablon funksiyalar yaratish va ulardan foydalanish.
Shablon sinflar yaratish va ulardan foydalanish.
Shablon funksiyalarda funksiyalarni qayta yuklash mexanizmi.
Reja:
3. 1.Chiziqli jarayonlarni tashkil etish (Algoritm va dastur).
Har qanday murakkab algoritmni ham uch asosiy struktura yordamida
tasvirlash mumkin. Bular ketma-ketlik, ayri va takrorlash strukturalaridir. Ushbu
strukturalar asosida chiziqli, tarmoqlanuvchi va takrorlanuvchi hisoblash
jarayonlarining algoritmlarini tuzish mumkin. Umuman olganda, algoritmlarni
shartli ravishda quyidagi turlarga ajratish mumkin:
- chiziqli algoritmlar;
- tarmoqlanuvchi algoritmlar;
- takrorlanuvchi algoritmlar;
- ichma-ich joylashgan takrorlanuvchi algoritmlar;
- rekurrent algoritmlar;
- takrorlanishlar soni oldindan no’malum algoritmlar;
- ketma-ket yaqinlashuvchi algoritmlar.
Faqat ketma-ket bajariladigan amallardan tashkil topgan algoritmlarga -
chiziqli algoritmlar deyiladi. Bunday algoritmni ifodalash uchun ketma-ketlik
strukturasi ishlatiladi. Strukturada bajariladigan amal mos keluvchi shakl bilan
ko‘rsatiladi. Chiziqli algoritmlar blok-sxemasining umumiy tuzilishi 1.4-rasmda
keltirilgan.
1-misol. Uchburchak tomonlarining uzunligi bilan berilgan. Uchburchakka
ichki r va tashqi R chizilgan aylanalar radiuslarini hisoblang.
Ichki chizilgan aylana radiusi r = (a+b+c)/2S, tashqi chizilgan aylana
radiusi R= 4S
abc
formulalar orqali hisoblanadi. Bu yerda S - uchburchakning yuzi, a,
b, c – uchburchak tomonlarining uzunliklari. Masala echimining blok-sxemasi
Chiziqli algoritmlar. Bu turdagi algoritmlarda hech qanday shart tekshirilmaydi. Shu sababli barcha ko‘rsatmalar
ketmaket bajarib boriladi. «G‘ishtlar sonini hisob!ash», «Doira yuzini
hisoblash» algoritmlari chiziqli algoritmlarga misol bo'ladi. Le- kin hayotimizdagi juda ko‘p jarayonlar shartlar asosida
bosh- qariladi.
4. Algoritm so‘zi buyuk matematik Al-Xorazmiyning nomi bilan bog‘liq bo‘lib, u birinchi bo‘lib
arab raqamlaridan foydalangan holda arifmetik amallarni bajarish qoidasini bayon etdi.
Har qanday qo‘yilgan masalani kompyuterda echish uchun oldin uning echish usulini
tanlab, keyin uning algoritmini ishlab chiqish kerak bo‘ladi. Demak, hech bir masala yo‘qki
uning echilish yo‘llarini bilmasdan va algoritmini tasavvur qilmasdan turib uni kompyuterda
echib bo‘lmaydi.
2.Algoritm va uning xossalari
Elektron hisoblash mashinalarining vujudga kelishiga qadar algoritmga har xil ta’rif berib
kelindi. Lekin ularning barchasi ma’no jihatdan bir-biriga juda yaqin bo‘lib, bu ta’rif hozirgi
kunda quyidagicha talqin qilinadi.
Ta’rif. Algoritm deb, qo‘yilgan masalani echish uchun ma’lum qoidaga binoan bajariladigan
amallarning chekli qadamlar ketma-ketligiga aytiladi.
Har qanday algoritm ma’lum ko‘rsatmalarga binoan bajariladi va bu ko‘rsatmalarga buyruq
deyiladi.
Algoritm quyidagi muhim xossalarga ega:
Aniqlik va tushunarlilik - deganda algoritmda ijrochiga berilayotgan ko‘rsatmalar aniq
mazmunda bo‘lishi tushuniladi.
Ommaviylik - deganda har bir algoritm mazmuniga ko‘ra bir turdagi masalalarning
barchasi uchun ham o‘rinli bo‘lishi tushuniladi.
Natijaviylik - deganda algoritmda chekli qadamlardan so‘ng albatta natija bo‘lishi
tushuniladi.
Diskretlik - deganda algoritmlarni chekli qadamlardan tashkil qilib bo‘laklash imkoniyati
tushuniladi.
3.Algoritm turlari
Algoritmning uchta turi bor: chiziqli, tarmoqlanuvchi va takrorlanuvchi.
CHiziqli algoritm - deb hech qanday shartsiz faqat ketma-ket bajariladigan jarayonlarga
aytiladi.
5. 2.Sinflarni yaratishda operatorlarni qayta yuklash mexanizmidan unumli foydalanish.
C # har qanday dasturlash tili singari, o'rnatilgan turlarda asosiy operatsiyalarni bajarish uchun ishlatiladigan tayyor leksemalar to`plamiga ega.
Masalan, + operatsiyasini ikkita butun sonni qo`shishga uchun ishlatish mumkinligi ma'lum:
/ Butun sonlar bilan + operatsiyasi.
int a = 100;
int b = 240;
int c = a + b; // c endi 340 ga teng
Bu erda hech qanday yangilik yo'q, lekin siz bir xil operatsiyani C # o'rnatilgan ma'lumotlarning aksariyatiga qo'llash mumkin deb o'ylaganmisiz?
Masalan, kodni quyidagicha ko'rib chiqing:
// satrlar bilan + operatsiyasi.
satr si = "Salom";
satr s2 = "dunyo!";
satr s3 = si + s2; // s3 endi "Salom dunyo!"
Binar operatorlarni qayta yuklash
namespace ConsoleApplication1
{
class MyArr
{
// Uch o`lchovli fazoda koordinatalar
public int x, y, z;
public MyArr(int x = 0, int y = 0, int z = 0)
{
this.x = x;
this.y = y;
this.z = z;
}
Biri char - uni ko'rib chiqdik. Ikkinchisi int dir. Mashinalarning arhitekturasi qanday kattalikda bo'lsa, int tipining ham kattakigi huddi shunday bo'ladi. 16
bitlik mashinalarda int 16 bit edi. Hozirda esa int ning uzunligi 32 bitdir. int (integer - butun son) tipi charga o'hshaydi. Farqi bir baytdan kattaligidadir.
16 bitli int ning sig'imi -32768 dan +32767 gachadir. 32 bitli int esa -2 147 483 648 dan +2 147 483 647 gacha o'rin egallaydi. Bu ikki butun son tipidan
tashqari C++ da ikki tur vergulli, (nuqtali) yani haqiqiy son tipi mavjud. Bulardan biri float, hotirada 4 bayt joy egallaydi.
Ikkinchisi esa double, 8 bayt kattalikka ega. Bularning harakteristikalari quyidagi jadvalda berilgan. Ushbu tiplar bilan ishlaganda unsigned(ishorasiz, +/-
siz), signed (ishorali) long (uzun) va short (qisqa) sifatlarini qo'llasa bo'ladi. unsigned va signed ni faqat butun son tiplari bilan qo'llasa bo'ladi.
6. Operatorlarni qayta yuklash asoslari
•C # har qanday dasturlash tili singari, o'rnatilgan turlarda asosiy operatsiyalarni bajarish
uchun ishlatiladigan tayyor leksemalar to`plamiga ega. Masalan, + operatsiyasini ikkita
butun sonni qo`shishga uchun ishlatish mumkinligi ma'lum:
•/ Butun sonlar bilan + operatsiyasi.
•int a = 100;
•int b = 240;
•int c = a + b; // c endi 340 ga teng
Operatorlarni qayta yuklash asoslari
•Bu erda hech qanday yangilik yo'q, lekin siz bir xil operatsiyani C # o'rnatilgan
ma'lumotlarning aksariyatiga qo'llash mumkin deb o'ylaganmisiz? Masalan, kodni
quyidagicha ko'rib chiqing:
•// satrlar bilan + operatsiyasi.
•satr si = "Salom";
•satr s2 = "dunyo!";
•satr s3 = si + s2; // s3 endi "Salom dunyo!"
7. Funktsiya shablonlari
Funktsiyalar va sinflar samarali dasturlash uchun kuchli va moslashuvchan vositalar bo'lsa-da, ular ba'zi hollarda C++ ning
foydalaniladigan barcha parametrlarning turlarini belgilash talabi tufayli cheklangan. Masalan, ikkita sonning eng kattasini
hisoblash uchun funksiya yozishimiz kerak deylik:
Agar biz butun sonlar bilan ishlasak, hamma narsa yaxshi. Ammo agar biz ikki tomonlama qiymatlar bilan ishlashimiz kerak
bo'lsa-chi? Ehtimol, ikki turdagi bilan ishlash uchun max() funksiyasini ortiqcha yuklashga qaror qilasiz:
Endi bizda char, int, double va > operatorini haddan tashqari yuklasak, hatto sinflar bilan ishlaydigan bir xil funktsiyaning ikkita
versiyasi mavjud! Biroq, C++ bizdan o'zgaruvchilarning turlarini ko'rsatishni talab qilganligi sababli, biz bir xil funktsiyaning bir
nechta versiyasini yozishimiz kerak, bu erda faqat parametrlar turi o'zgaradi. Va bu, o'z navbatida, dasturchilar uchun bosh
og'rig'i, chunki bunday kodni saqlash kuch va vaqt jihatidan oson emas. Va eng muhimi, bu samarali dasturlash
tushunchalaridan birini buzadi - kodlarning takrorlanishini minimallashtirish. Har qanday turdagi parametrlar bilan ishlaydigan
max() funksiyasining bitta versiyasini yozish yaxshi emasmi?
Bu mumkin. Shablonlar dunyosiga xush kelibsiz!
Agar lug‘atdagi “shablon” so‘zining ta’rifiga e’tibor qaratsangiz, biz quyidagilarni ko‘ramiz: “Shablon – shunga o‘xshash
mahsulotlar tayyorlanadigan namunadir”. Misol uchun, shablon stencil - chizma / naqsh / belgi kesilgan ob'ekt (masalan,
plastinka). Agar biz boshqa ob'ektga trafaret yopishtirib, bo'yoq purkasak, biz minimal kuch bilan bir xil naqshni olamiz, tez va
eng muhimi, biz o'nlab bu naqshlarni turli rangda yasay olamiz! Bunday holda, bizga faqat bitta stencil kerak va biz rasmning
rangini oldindan aniqlashimiz shart emas (stencilni ishlatishdan oldin).
C++ tilida funksiya shablonlari boshqa shunga o'xshash funksiyalarni yaratish uchun shablon bo'lib xizmat qiladigan
funksiyalardir. Asosiy g'oya - ba'zi yoki barcha o'zgaruvchilarning aniq turini (turlarini) ko'rsatmasdan funktsiyalarni yaratish.
Buning uchun har qanday ma'lumotlar turi o'rniga qo'llaniladigan shablon parametrining turini ko'rsatuvchi funktsiyani
aniqlaymiz. Shablon parametr turiga ega funktsiyani yaratganimizdan so'ng, biz samarali tarzda "funktsiya trafaretini" yaratadi.
3.Shablon funksiyalar yaratish va ulardan foydalanish.
8. Funksiya shablonini chaqirganda, kompilyator funksiya uchun shablon sifatida "trafaret" dan foydalanadi, shablon
parametri turini funktsiyaga uzatilgan o'zgaruvchilarning haqiqiy turi bilan almashtiradi! Shunday qilib, biz faqat bitta
shablon yordamida funktsiyaning 50 ta "soyasini" yaratishimiz mumkin
Hozircha siz C++ da funksiya shablonlari qanday yaratilganiga qiziqayotgandirsiz. Bu unchalik qiyin emasligi ma'lum
bo'ldi. max() funksiyasining butun son versiyasini yana bir bor ko'rib chiqing:
Bu erda biz ma'lumotlar turini uch marta aniqlaymiz: a, b parametrlarida va funktsiyaning qaytish turida. Bu funksiya
uchun shablon yaratish uchun int turini funksiya shablon parametri turiga almashtirishimiz kerak. Bu holatda faqat bitta
ma'lumot turi (int) ishlatilganligi sababli, biz shablon parametrlarining faqat bitta turini ko'rsatishimiz kerak.
Biz bu turni har qanday nomlashimiz mumkin, agar u zaxiralangan/kalit so'z bo'lmasa. C++ tilida bosh T harfi bilan
shablon parametrlari turlariga murojaat qilish odatiy holdir (“Type” so‘zining qisqartmasi).
Mana bizning o'zgartirilgan max() funksiyamiz:
Lekin bu hammasi emas. Dastur ishlamaydi, chunki kompilyator T nima ekanligini bilmaydi!
Buni amalga oshirish uchun biz kompilyatorga ikkita narsani aytishimiz kerak:
Funktsiya shablonining ta'rifi.
T funksiya shablon parametrining turi ekanligini ko'rsatadi.
Biz buni bitta kod qatorida shablon deklaratsiyasini (aniqrog'i, shablon parametrlari deklaratsiyasini) bajarish orqali
amalga oshirishimiz mumkin:
Keling, shablon parametrlari deklaratsiyasini batafsil ko'rib chiqaylik:
Birinchidan, biz shablon kalit so'zini yozamiz, bu esa kompilyatorga shablon parametrlarini keyingi e'lon qilishimizni
aytadi.
Funktsiya shablonining parametrlari burchakli qavslarda ko'rsatilgan.
Typename va class kalit so'zlari shablon parametr turlarini yaratish uchun ishlatiladi. Funktsiya shablonlarini ishlatishning
asosiy holatlarida tip nomi va sinf o'rtasida farq yo'q, shuning uchun siz ikkalasidan birini tanlashingiz mumkin. Agar siz
class kalit so'zidan foydalansangiz, parametrlarning haqiqiy turi sinf bo'lishi shart emas (bu asosiy ma'lumotlar turining
o'zgaruvchisi, ko'rsatgich yoki boshqa narsa bo'lishi mumkin).
Keyin shablon parametrining turini nomlaymiz (odatda T).
Agar bir nechta shablon parametrlari kerak bo'lsa, ular vergul bilan ajratiladi:
Agar bir nechta parametrlar mavjud bo'lsa, ular odatda T1, T2 yoki boshqa harflar deb ataladi
9. 4.Shablon sinflar yaratish va ulardan foydalanish.
Funktsiya shablonlaridan foydalanish
Funktsiya shablonlaridan foydalanish oddiy funktsiyalardan foydalanishga o'xshaydi:
E'tibor bering, max() funksiyasiga uchta qo'ng'iroq ham har xil turdagi parametrlarga ega! Biz max() funksiyasini uch xil turdagi parametrlar bilan chaqirayotganimiz sababli,
kompilyator max() funksiyasining uch xil versiyasini yaratish uchun funksiya shablonidan foydalanadi:
int tipidagi parametrlarga ega versiya (max).
Double tipidagi parametrlarga ega versiya (max).
tartipidagi parametrlarga ega versiya (max).
O'tkazilayotgan qiymatlar turini (max ning qismi) aniq ko'rsatishning hojati yo'q, kompilyator buni o'zi aniqlaydi.
Funktsiya shablonlari ko'p vaqtni tejaydi, chunki biz shablonni faqat bir marta yozamiz va biz uni har xil turdagi ma'lumotlar bilan ishlatishimiz mumkin. Funktsiya shablonlarini
yozishga odatlanganingizdan so'ng, oddiy funktsiyani yozish uchun ko'proq vaqt talab qilinmasligini bilib olasiz (muntazam funktsiyaning bitta versiyasi). Funktsiya shablonlari
kodni keyinchalik saqlashni ancha osonlashtiradi va ular xavfsizroqdir, chunki kodni nusxalash orqali funktsiyani qo'lda ortiqcha yuklashingiz shart emas va faqat yangi
ma'lumotlar turini qo'llab-quvvatlashingiz kerak bo'lganda ma'lumotlar turlarini o'zgartirishingiz shart emas.
Funktsiya shablonlarining bir nechta kamchiliklari bor va agar ular haqida gapirmasak, kechirib bo'lmaydi:
1. Birinchidan, ba'zi eski kompilyatorlar funksiya shablonlarini qo'llab-quvvatlamasligi mumkin yoki ular mumkin, lekin cheklovlar bilan. Biroq, bu endi avvalgidek muammo
emas.
2. Ikkinchidan, funktsiya shablonlari ko'pincha aqldan ozgan xato xabarlarini ishlab chiqaradi, bu oddiy funktsiya xatolaridan ko'ra shifrlash qiyinroq.
3. Uchinchidan, funksiya shablonlari kompilyatsiya vaqtini va kod hajmini oshirishi mumkin, chunki bitta shablonni bir nechta fayllarda “amalga oshirish” va qayta kompilyatsiya
qilish mumkin.
Funktsiya shablonlarining kuchi va moslashuvchanligi bilan solishtirganda, bu kamchiliklar juda kichikdir!
Shablonlar ba'zi parametrlarga (masalan, ma'lumotlar turlari, bufer o'lchamlari, standart qiymatlar) bog'lanmagan holda umumlashtirilgan algoritmlarni kodlash uchun
mo'ljallangan C++ tili vositasidir.
C++ da funksiya va sinf shablonlarini yaratish mumkin.
Shablonlar parametrlangan sinflar va funksiyalarni yaratishga imkon beradi. Parametr har qanday turdagi yoki ruxsat etilgan turlardan birining qiymati bo'lishi mumkin (integer,
enum, global kirish mumkin bo'lgan nomga ega har qanday ob'ektga ko'rsatgich, mos yozuvlar). Masalan, bizga qandaydir sinf kerak:
Bitta aniq maqsadda biz ushbu sinfdan foydalanishimiz mumkin. Ammo, to'satdan, maqsad biroz o'zgardi va boshqa sinf kerak. Endi bizga SomeArray massivining 30 ta
elementi va SomeArray elementlarining haqiqiy turi SomeValue kerak. Keyin biz aniq turlardan mavhum bo'lishimiz va parametrlarga ega shablonlardan foydalanishimiz
mumkin. Sintaksis: boshida, sinfni e'lon qilishdan oldin, biz shablonni, ya'ni shablonni e'lon qilamiz va burchakli qavslar ichida parametrlarni belgilaymiz. Bizning misolimizda:
Keyin birinchi holat uchun (20 ta elementdan iborat SomeValue va SomeArray butun soni bilan) biz yozamiz:
SomeClass < 20, int > SomeVariable;
ikkinchisi uchun:
SomeClass < 30, double > SomeVariable2;
Shablonlar kod bo'lagi uchun stenografiya taqdim etsa-da, ulardan foydalanish bajariladigan kodni qisqartirmaydi, chunki kompilyator har bir variant to'plami uchun funksiya
yoki sinfning alohida nusxasini yaratadi. Natijada, umumiy kutubxonalar ichida kompilyatsiya qilingan kodni almashish imkoniyati yo'qoladi.
10. Shablon tavsifi sintaksisi
Funktsiya shabloni shablon kalit so'zidan boshlanadi, undan keyin burchakli qavslar ichidagi parametrlar ro'yxati keladi. Keyin funksiya deklaratsiyasi keladi:
shablon
bekor tartiblash ( T massivi [], int o'lchami ); // prototip: tartiblash shabloni e'lon qilingan, lekin aniqlanmagan
shablon
void sort( T array[], int size ) // deklaratsiya va ta'rif
{
Tt;
uchun (int i = 0; i < hajmi - 1; i++)
uchun (int j = o'lcham - 1; j > i; j--)
agar (massiv[j]
{
t = massiv[j];
massiv[j] = massiv[j-1];
massiv[j-1] = t;
}
}
shablon< int BufferSize > // butun son parametri
char * o'qish ()
{
char *Bufer = yangi belgi[ BufferSize ];
/* maʼlumotlarni oʻqish */
qaytarish buferi;
}
Typename kalit so'zi nisbatan yangi, shuning uchun standart[1] typename o'rniga sinfdan foydalanishga imkon beradi:
shablon
T o'rniga har qanday boshqa identifikator qabul qilinadi.
Foydalanish misoli
Eng oddiy misol - minimal ikki miqdorni aniqlash.
Agar a b dan kichik bo'lsa, a, aks holda b ni qaytaring
Shablonlar bo'lmasa, dasturchi foydalanilgan har bir ma'lumot turi uchun alohida funktsiyalarni yozishi kerak. Garchi ko'pgina dasturlash tillari elementar turlar (masalan, butun
sonlar va haqiqiy sonlar) uchun o'rnatilgan minimal funktsiyani aniqlasa ham, bunday funktsiya murakkab (masalan, "vaqt" yoki "string") va juda murakkab ("" uchun" kerak bo'lishi
mumkin. o'yinchi" onlayn o'yinda) ob'ektlar .
11. C++ da umumiy turlardan foydalangan holda shablon funksiyalar va sinflar yaratish
mumkin. Shablon funksiyalar va sinflar ko’plab turli ma’lumot turlari bilan ishlay oladi.
C++ da umumiy tur uchun dasturlash mumkin. Misol uchun, umumiy turdagi ikki
sondan kattasini aniqlovchi funksiya yaratdingiz. Agar siz funksiyani int argumentlar
uchun chaqirishingiz kerak bo’lsa, u holda umumiy tur int turi bilan almashitriladi. Agar
siz funksiyani ikki double argumentlar uchun chaqirmoqchi bo’lsangiz, u holda umumiy
tur double turi bilan almashtiriladi.
Shablonlar asoslari
Shablonlar sinflar va funksiyalarda turlarni parametrlashtirish imkoniin beradi. Siz
funksiyalar va sinflarni umumiy tur bilan aniqlay olasiz. Keyinchalik ular kompilyator
tomonidan aniq bir tur bilan ishlatiladi.
Shablon tushunchasini yoritib beradigan misol qaraymiz. Tasavvur qiling, ikkita butun,
ikkita haqiqiy, ikkita belgi va ikki satrlardan kattasini aniqlash kerak. Buning uchun
quyidagicha qayta yuklangan 4 ta funksiya yozilishi kerak:
Shablonlar asoslari
Yuqoridagi 4 funksiya deyarli bir xil, farqi faqat turlarida. Birinchi funksiyada
int, ikkinchisida double, uchinchisida char va to’rtinchisida string turlaridan
foydalanilmoqda. Agar funksiya quyidagicha umumiy tur orqali yaratilsa, u holda turlar
soni ko’p bo’lib ketmaydi va dastur kodi ham uzun bo’lib ketmaydi:
Bu yerda GenericType int, double, char va string turlaridan biri bo’la oladi.
12. 5.Shablon funksiyalarda funksiyalarni qayta yuklash mexanizmi.
M a’lumki, funksiyalarni aniqlashda ulam ing qaytarishi lozim
bo‘lgan qiymatlar tipi va funksiya uchun zarur bo ‘lgan parametrlar
tipini ko'rsatish lozim edi.
Faraz qilaylik, ikkita butun sonni q o ‘shish uchun funksiya
ciurilgan b o ‘lsin. Agar uchta butun sonni q o ‘shish talab qilingan
bo‘lsa, ular uchun boshqa nomdagi funksiyani qurish talab qilinadi.
Ikkita haqiqiy sonni qo‘shish uchun esa boshqa funksiya qurish lozim
bo'ladi.
Bunday hollarda bir xil funksiyani takror va takror yozishning
o'm iga, C++ tili bir xil nomdagi funksiyalarni qurish imkonini beradi.
Dastumi kompilatsiya qilish jarayonida C++ funksiyalaming har
biridagi argumentlar miqdori e ’tiborga olinadi va aynan kerak bo'lgan
funksiyani chaqiradi. Kompilyatorga bir nechta funksiyalar orasidan
kcragini tanlash imkoniyati funksiyalarni qayta yuklash deb ataladi.
105Funksiyalami qayta yuklash amali bir xil nomdagi param etrlam i
har xil tipga mansub b o ‘lgan turli funksiyalar uchun qo‘llashga ruxsat
beradi.
Masalan, quyidagi dastur addjvalues nomli ikkita funksiyani
qayta yuklash uchun xizmat qiladi:
#include
int add_values (int a, int b)
{
return(a + b);
}
int add_values (int a, int b, int c)
13. C++ da dasturlashning asosiy bloklaridan biri funksiyalardir. Funksiyalar dasturchi ishini juda
yengillashtiradi. Funksiyalar yordamida programma modullashadi, qismlarga bo'linadi. Bu esa
keyinchalik dasturni rivojlantirishni osonlashtiradi. Bunda dasturchi yozgan funksiyalar C++
ning standart kutubhonasi va boshqa kutubhonalar ichidagi funksiyalar bilan birlashtiriladi. Bu
esa ishni osonlashtiradi. Ko'p holda dasturda takroran bajariladigan amalni funksiya sifatida
yozish va kerakli joyda ushbu funksiyani chaqirish mumkin. Dastur yozilish davrida hatolarni
topishni yengillashtiradi. Bir misolda funksiyaning asosiy qismlarini ko'rib chiqaylik: int foo(int
k, int t) { int result; result = k * t; return (result); }
Yuqoridagi foo funksiyamizning ismi, () qavslar ichidagi parametrlar – int tipidagi k va t lar
kirish argumentlaridir, ular faqat ushbu funksiya ichida ko'rinadi va qo'llaniladi. Bunday
o'zgaruvchilar lokal (local - mahalliy) deyiladi. result foo() ning ichida e’lon qilinganligi uchun
u ham lokaldir. Demak biz funksiya ichida o'zgaruvchilarni va sinflarni (class) e’lon qilishimiz
mumkin ekan. Lekin funksiya ichida boshqa funksiyani e’lon qilib bo'lmaydi. foo() funksiyamiz
qiymat ham qaytaradi. Qaytish qiymatining tipi foo() ning e’lonida eng boshida kelgan - int
tipiga ega. Biz funksiyadan qaytarmoqchi bo'lgan qiymatning tipi ham funksiya e’lon qilgan
qaytish qiymati tipiga mos kelishi kerak - ayni o'sha tipda bo'lishi yoki o'sha tipga keltirilishi
mumkin bo'lgan tipga ega bo'lishi shart. Funksiyadan qiymatni return ifodasi bilan qaytaramiz.
Agar funksiya hech narsa qaytarmasa e’londa void tipini yozamiz. Ya’ni: void funk() { int g =
10; cout << g; return; }
14. Bu funksiya void (bo’sh, hech narsasiz) tipidagi qiymatni qaytaradi. Boshqacha qilib aytganda qaytargan qiymati
bo’sh to’plamdir. Lekin funksiya hech narsa qaytarmaydi deya olmaymiz. Chunki hech narsa qaytarmaydigan
mahsus funksiyalar ham bor. Ularning qaytish qiymati belgilanadigan joyga hech narsa yozilmaydi. Biz unday
funksiyalarni keyinroq ko’rib chiqamiz. Bu yerda bir nuqta shuki, agar funksiya mahsus bo’lmasa, lekin oldida
qaytish qiymati tipi ko’rsatilmagan bo'lsa, qaytish qiymati int tipiga ega deb qabul qilinadi. void qaytish tipli
funksiyalardan chiqish uchun return; deb yozsak yetarlidir. Yoki return ni qoldirib ketsak ham bo’ladi.
Funksiyaning qismlari bajaradan vazifasiga ko’ra turlicha nomlanadi. Yuqorida korib chiqqanimiz funksiya
aniqlanishi (function definition) deyiladi, chunki biz bunda funksiyaning bajaradigan amallarini funksiya
nomidan keyin, {} qavslar ichida aniqlab yozib chiqyapmiz. Funksiya aniqlanishida {} qavslardan oldin nuqta-
vergul (;) qo'yish hatodir. Bundan tashqari funksiya e’loni, prototipi yoki deklaratsiyasi (function prototype)
tushunchasi qo'llaniladi.
Bu funksiya void (bo’sh, hech narsasiz) tipidagi qiymatni qaytaradi. Boshqacha qilib aytganda
qaytargan qiymati bo’sh to’plamdir. Lekin funksiya hech narsa qaytarmaydi deya olmaymiz. Chunki
hech narsa qaytarmaydigan mahsus funksiyalar ham bor. Ularning qaytish qiymati belgilanadigan
joyga hech narsa yozilmaydi. Biz unday funksiyalarni keyinroq ko’rib chiqamiz. Bu yerda bir nuqta
shuki, agar funksiya mahsus bo’lmasa, lekin oldida qaytish qiymati tipi ko’rsatilmagan bo'lsa, qaytish
qiymati int tipiga ega deb qabul qilinadi. void qaytish tipli funksiyalardan chiqish uchun return; deb
yozsak yetarlidir. Yoki return ni qoldirib ketsak ham bo’ladi. Funksiyaning qismlari bajaradan
vazifasiga ko’ra turlicha nomlanadi. Yuqorida korib chiqqanimiz funksiya aniqlanishi (function
definition) deyiladi, chunki biz bunda funksiyaning bajaradigan amallarini funksiya nomidan keyin, {}
qavslar ichida aniqlab yozib chiqyapmiz. Funksiya aniqlanishida {} qavslardan oldin nuqta-vergul (;)
qo'yish hatodir. Bundan tashqari funksiya e’loni, prototipi yoki deklaratsiyasi (function prototype)
tushunchasi qo'llaniladi.