Skip to main content

AI Agents: What They Are and How They Will Change Work

Artificial intelligence has moved beyond simply answering questions and generating text. A new generation of AI systems—known as AI agents—is emerging with the ability to plan tasks, use tools, make decisions, and complete multi-step workflows with less human intervention. From managing emails and analyzing data to writing software and assisting customers, AI agents could significantly change how people work. What Are AI Agents? An AI agent is a software system that can perceive information, reason about a goal, take actions, and adapt based on the results. Traditional AI tools usually respond to a specific instruction. For example, you might ask an AI chatbot to summarize a document, and it provides a summary. An AI agent can go further. You could give an agent a goal such as: "Research three competitors, compare their pricing, summarize their main features, and prepare a report." The agent may then: 1) Understand the objective. 2) Break the task into smaller steps. 3) Searc...

Input and Output Functions

INPUT AND OUTPUT FUNCTIONS
The most fundamental operation in a C program is to accept input values from a standard input device and output the data produced by the program to a standard output device. we can assign values to variables using the assignment operator ‘=’. For example,
int a = 3;
What if we want to assign value to variable a that is inputted from the user at run-time? This is done by using the scanf function that reads data from the keyboard. Similarly, for outputting results ofthe program, printf function is used that sends results to a terminal. Like printf and scanf, there are different functions in C that can carry out the input–output operations. These functions are collectively known as Standard Input/ Output Library. A program that uses standard input/output functions must contain the following statement at the beginning of the program:
#include <stdio.h>

scanf()
The scanf()function is used to read formatted data from the keyboard. The syntax of the scanf() function can be given as,
scanf ("control string", arg1, arg2, arg3...argn);
The control string specifies the type and format of the data that has to be obtained from the keyboard and stored in the memory locations pointed by the arguments, arg1, arg2, ...,argn. The prototype of the control string can be given as,
%[*][width][modifier]type
* is an optional argument that suppresses assignment of the input field. That is, it indicates that data should be read from the stream but ignored (not stored in the memory location).
width is an optional argument that specifies the maximum number of characters to be read. However, if the scanf function encounters a white space or an unconvertible character, input is 
terminated.
modifier is an optional argument (h, l, or L), which modifies the type specifier. 
Modifier h is used for short int or unsigned short int, l is used for long int, unsigned long int, or double values. Finally, L is used for long double data values.
type specifies the type of data that has to be read. It also indicates how this data is expected to be read from the user. The type specifiers for scanf function are given Table :  Type specifiers
Type      Qualifying Input
%c           For single characters
%d,          %i For integer values
%e,          %E,%f,%g,%G For floating point  numbers
%o            For octal numbers
%s             For a sequence of (string of) characters
%u             For unsigned integer values
%x,%X       For hexadecimal values
The scanf function ignores any blank spaces, tabs, and newlines entered by the user. The function simply returns the number of input fields successfully scanned and stored.
As we have not studied functions till now, understanding scanf function in depth will be a bit difficult here, but for now just understand that the scanf function is used to store values in memory locations associated with variables. For this, the function should have the address of the variables. The address of the variable is denoted by an & sign followed by the name of the variable. Look at the following code that shows how we can input value in a variable of int data type:
int num;
scanf(" %4d ", &num);
The scanf function reads first four digits into the address or the memory location pointed by num.

printf()
The printf function is used to display information required by the user and also prints the values of the variables. Its syntax can be given as:
printf ("control string", arg1,arg2,arg3,...,argn);
After the control string, the function can have as many arguments as specified in the control string. The control string contains format specifiers which are arranged in the order so that they 
correspond with the arguments in the variable list. It may also contain text to be printed such as instructions to the user, identifier names, or any other text to make the text readable.
Note that there must be enough arguments because if there are not enough arguments, then the result will be completely unpredictable. However, if by mistake you specify more number of 
arguments, the excess arguments will simply be ignored. The prototype of the control string can be given as below:
%[flags][width][.precision][modifier]type
Each control string must begin with a % sign. 
flags is an optional argument, which specifies output justification like decimal point, numerical sign, trailing zeros or octadecimal or hexadecimal prefixes. Below Table shows different types of flags with their descriptions.
Table : Flags in printf()
Flags      Description
–             Left–justify within the given field width
+             Displays the data with its numeric sign (either + or –)
#           Used to provide additional specifiers like o, x, X, 0, 0x, or 0X for
octal and hexadecimal values respectively for values different than zero
0          The number is left–padded with zeroes (0) instead of spaces.
width is an optional argument which specifies the minimum number of positions that the output characters will occupy. If the number of output characters is smaller than the specified width, then the output would be right justified with blank spaces to the left. However, if the number of characters is greater than the specified width, then all the characters would be printed.
precision is an optional argument which specifies the number of digits to print after the decimal point or the number of characters to print from a string. 
modifier field is same as given for scanf() function. 
type is used to define the type and the interpretation of the value of the corresponding argument. 
The type specifiers for printf function are given 
The most simple printf statement is
printf ("Welcome to the world of C language");
The function when executed prompts the message enclosed in the quotation to be displayed on the screen.
For float x = 8900.768, the following examples show output under different format specifications:
printf ("%f", x) 8 9 0 0 . 7 6 8
printf("%10f", x); 8 9 0 0 . 7 6 8
printf("%9.2f", x); 8 9 0 0 . 7 7
printf("%6f", x); 8 9 0 0 . 7 6 8

Popular posts from this blog

MEMORY MAPPED FILES

Memory-mapped files           Rather than retriving data files directly via the file system with every file access, data files can be paged into memory the same as process files, resulting in much faster retrieves ( except of course when page-faults occur. ) This is called as memory-mapping a file. Basic Mechanism * Basically a file is mapped to an address range within a process's virtual address space, and then paged in as required using the ordinary demand paging system. * Note that file matches are made to the memory page frames, and are not immediately written out to disk. ( This is the purpose of the "flush( )" system call, which may also be needed for stdout in some cases. See the time killer program for an example of this) * This is also why it is important to "close()" a file when one is done writing to it - So that the data can be safely flushed out to disk and so that the memory frames can be release for other purposes. * Some systems issue special sys...

Embracing the Future: Resource Recovery from Waste

As global populations swell and industrial activities intensify, the amount of waste we generate is skyrocketing. Landfills, once considered an adequate solution, are now recognized as unsustainable and environmentally damaging. Enter resource recovery from waste – a transformative approach that views waste not as a problem, but as a potential treasure trove of resources. This blog post delves into the concept, methods, and benefits of resource recovery, illuminating how this practice is reshaping waste management and sustainability. What is Resource Recovery? Resource recovery refers to the process of extracting useful materials or energy from waste. Instead of simply discarding waste, resource recovery emphasizes reusing, recycling, and repurposing materials to reduce the volume of waste sent to landfills and minimize environmental impact. Key Methods of Resource Recovery Recycling: This is perhaps the most well-known form of resource recovery. Recycling involves converting waste mat...

Understanding Surface and Groundwater Quality Modelling

Introduction Water is one of our planet's most precious resources, essential for all forms of life. With increasing pressures from human activities and climate change, understanding and managing water quality has become crucial. Surface and groundwater quality modelling are vital tools in this endeavor, providing insights that guide sustainable water resource management and policy-making. What is Water Quality Modelling? Water quality modelling involves the use of mathematical simulations to predict the physical, chemical, and biological characteristics of water bodies. These models help scientists and policymakers understand how various factors affect water quality and allow them to test different scenarios to predict future conditions and assess the effectiveness of management strategies. Surface Water Quality Modelling Key Components Hydrodynamics: This involves the study of water flow in rivers, lakes, and reservoirs. Hydrodynamic models simulate the movement of water, which i...