0% found this document useful (0 votes)
4 views

c ppt1

The document discusses the production of COVID vaccines in Lemoland, detailing two companies' production schedules and rates. It includes a structure for a C program that calculates the number of days required to produce a specified number of vaccines based on input parameters. Additionally, it provides examples of input and output for the program, demonstrating how to determine the total vaccines produced over time.

Uploaded by

saipranya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

c ppt1

The document discusses the production of COVID vaccines in Lemoland, detailing two companies' production schedules and rates. It includes a structure for a C program that calculates the number of days required to produce a specified number of vaccines based on input parameters. Additionally, it provides examples of input and output for the program, demonstrating how to determine the total vaccines produced over time.

Uploaded by

saipranya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

PRESENTED BY,

NAME:LAMBU.VYSHNAVI
ROLL NO:21951A67J6
BRANCH:CSD-C
SUBJECT: PROGRAMMING
FOR PROBLEM SOLVING
Increasing covid Cases have created panic
amongst the people of Lemoland,so the
government is starting to push for production of
a vaccine.It has to report to the media about
the exact date when vaccines will be
available.There are two companies which are
producing vaccines for covid.Company A starts
producing vaccines on day D1 and it can
Produce V1 vaccines per day. Company B starts
producing vaccines on day D2 and It can
Produce V2 vaccines per day. Currently,we are
on day1. We need a total of P vaccines. How
many days are required to produce enough
Structure of a C program:
Header Files Inclusion:
The first and foremost component is the inclusion of
the Header files in a C program.
A header file is a file with extension .h which contains
C function declarations and macro definitions to be
shared between several source files.

#include<stdio.h>and void main () in


•program:
studio.h – Defines core input and output functions

stdio. h is a header file which has the necessary


information to include the input/output related functions
in our program. Example printf, scanf etc. If we want to
use printf or scanf function in our program, we should
include the stdio. h header file in our source code.
In computer programming, when void is used as a function
return type, it indicates that the function does not return
a value. When void appears in a pointer declaration, it
Main Method
Declaration: The next part
of a C program is to declare int
the main() function. The
syntax to declare the main
main()
function is: {}
Syntax to Declare the main
method
Variable Declaration: The next part
of any C program is the variable int main()
declaration. It refers to the
variables that are to be used in the {
function. Please note that in the C int a;
program, no variable can be used
without being declared. Also in a C }
program, the variables are to be
declared before any operation in
the function.
Body: The body of a int main()
function in the C program, {
refers to the operations int a;
that are performed in the
functions. It can be printf("%d",
anything like a);
manipulations, searching, }
sorting, printing, etc.
Return statement: The last part of
any C program is the return
statement. The return statement int main()
refers to the returning of the values {
from a function. This return int a;
statement and return value depend
printf("%d",
upon the return type of the function.
For example, if the return type is a);
void, then there will be no return return 0;
statement. In any other case, there }
will be a return statement and the
return value will be of the type of the
specified return type.
While
Loop:
A while loop in C programming repeatedly
executes a target statement as long as a
given condition is true.

while(condit
Syntax: ion) {
The syntax of a while loop in C
programming language is −
statement(s
);
}
Here, statement(s) may be
a single statement or a
block of statements.
The condition may be any
expression, and true is
any nonzero value. The
loop iterates while the
condition is true.
When the condition
becomes false, the
program control passes to
the line immediately
following the loop.
If Statement:
An if statement consists of a Boolean
expression followed by one or more
statements.
Syntax
The syntax of an 'if' statement in C programming
language is −

If the Boolean expression evaluates to true, then if(boolean_expres


the block of code inside the 'if' statement will be sion)
executed. If the Boolean expression evaluates
to false, then the first set of code after the end of
{
the 'if' statement (after the closing curly brace) will /* statement(s)
be executed. will execute if
C programming language assumes any non- the boolean
zero and non-null values as true and if it is expression is
either zero or null, then it is assumed
as false value.
true */
}
PROGRAMME:
INPUT:
The first and only line of the input contains
five space-separated integers D1,V1,D2,V2
and P

INPUT: OUTPUT:
1 2 1 3 14 3

Explanation:
Since D1= D2= 1, we can produce V1​+V2​
=5 vaccines per day. In 33 days, we
produce 1515 vaccines, which satisfies our
requirement of 1414 vaccines
INPUT: OUTPUT:
5 4 2 10 100 9

Explanation:
There are 00 vaccines produced on the first
day, 1010 vaccines produced on each of
days 22, 33 and 44, and 1414 vaccines produced on
the fifth and each subsequent day. In 99 days, it
makes a total of 0 + 10 \cdot 3 + 14 \cdot 5 =

You might also like