Skip to main content

Tesla Gigafactories: Powering the Future of Sustainable Transportation

Powering the Future of Sustainable Transportation Introduction One of the biggest reasons behind Tesla's rapid growth is its network of Gigafactories. These massive manufacturing facilities are designed to produce electric vehicles (EVs), batteries, energy storage systems, and other clean-energy products at an unprecedented scale. By building Gigafactories around the world, Tesla has transformed the way vehicles and batteries are manufactured, helping accelerate the global transition to sustainable energy. What is a Gigafactory? A Gigafactory is a large-scale manufacturing facility built by Tesla, Inc. to produce batteries, electric vehicles, and energy products. The name "Gigafactory" comes from the word "gigawatt-hour," reflecting the enormous battery production capacity of these plants. Tesla's goal is to reduce manufacturing costs, increase production efficiency, and make electric vehicles more affordable for consumers worldwide. Major Tesla Gigafactorie...

C program to find sum of digits of a number using recursion.

 C  program to find sum of digits of a number using recursion.

#include <stdio.h>
int sumOfDigits(int num);
int main() {
    int num, sum;
    printf("Enter a number: ");
    scanf("%d", &num);
    sum = sumOfDigits(num);
    printf("The sum of digits of %d is %d.\n", num, sum);
    return 0;
}

int sumOfDigits(int num) {
    if (num == 0) {
        return 0;
    } else {
        return (num % 10) + sumOfDigits(num / 10);
    }
}

Explanation : 

The program starts by including the standard input-output library stdio.h.

The program defines a function sumOfDigits that takes an integer argument num and returns the sum of its digits. The function is defined using recursion.

Inside the sumOfDigits function, there is an if statement that checks if the number num is equal to 0. If it is, the function returns 0 as the sum of digits.

If num is not equal to 0, the function calculates the sum of the last digit of num (obtained using the modulus operator %) and the sum of digits of the remaining digits (obtained using integer division /), and returns this sum.

The program defines the main function that takes no arguments and returns an integer. Inside the main function, the program declares three integer variables num, sum, and i.

The program prompts the user to enter a number using printf and reads the input using scanf.

The program calls the sumOfDigits function with the input number num and stores the result in the variable sum.

Finally, the program prints the result using printf.

The return 0 statement at the end of the main function terminates the program and returns 0 to the operating system.

Sample output :
Enter a number: 1234
The sum of digits of 1234 is 10.

Here, we have entered the number 1234 as input, and the program has calculated the sum of its digits (which is 1+2+3+4=10) using recursion and printed the result.


Popular posts from this blog

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...

Harnessing Remote Sensing and GIS for Environmental Management

In an era where environmental sustainability has become paramount, the tools and technologies we employ to monitor and manage our natural resources are more critical than ever. Remote sensing and Geographic Information Systems (GIS) are two such technologies that have revolutionized environmental management, providing unprecedented insights and enabling more effective decision-making. This blog post explores the roles of remote sensing and GIS in environmental management, their applications, and the benefits they bring. Understanding Remote Sensing and GIS Remote Sensing involves the acquisition of information about an object or phenomenon without making physical contact with it. This is typically achieved through the use of satellites or aircraft that capture data in the form of images or other sensor readings. The data collected can cover various wavelengths of the electromagnetic spectrum, providing detailed information about the Earth's surface and atmosphere. Geographic Inform...

Transitioning to a Low Carbon Economy:

Pathways and Potential In the wake of escalating climate change impacts, the global community is increasingly prioritizing the transition to a low carbon economy. This paradigm shift involves reducing carbon dioxide (CO2) and other greenhouse gas emissions through sustainable practices, innovative technologies, and forward-thinking policies. A low carbon economy aims to balance economic growth with environmental stewardship, ensuring a resilient and sustainable future for generations to come. Understanding the Low Carbon Economy A low carbon economy focuses on minimizing carbon footprints across all sectors, from energy production to transportation, agriculture, and manufacturing. The goal is to achieve substantial reductions in greenhouse gas emissions, ultimately limiting global warming to well below 2°C, as stipulated by the Paris Agreement. Key Strategies for Transition Renewable Energy Transition: Solar and Wind Power: Investing in solar and wind energy is crucial. These sources ...