100% toatl cost incurred while buying multiple items: nptel based class
// Online C compiler to run C program online
#include <stdio.h>
void main()
{
int i,no_of_fruits[4],pricepu[4],total=0;
/*let the fruits be araTi, kamalA (Nagpur), apple (himAchal pradEsh), sapOTA*/
for(i=0;i<4;i++)
{
printf("\n enter the no of fruits of type %d purchased:",i+1);
scanf("%d",&no_of_fruits[i]);
printf("\n enter price per unit of this fruit:");
scanf("%d",&pricepu[i]);
total=total+no_of_fruits[i]*pricepu[i];
}
printf("\n total cost of fruits=%d",total);
} /* పండ్లు ఆరోగ్యానికి మేలు*/
#include <stdio.h>
void main()
{
int i,no_of_fruits[4],pricepu[4],total=0;
/*let the fruits be araTi, kamalA (Nagpur), apple (himAchal pradEsh), sapOTA*/
for(i=0;i<4;i++)
{
printf("\n enter the no of fruits of type %d purchased:",i+1);
scanf("%d",&no_of_fruits[i]);
printf("\n enter price per unit of this fruit:");
scanf("%d",&pricepu[i]);
total=total+no_of_fruits[i]*pricepu[i];
}
printf("\n total cost of fruits=%d",total);
} /* పండ్లు ఆరోగ్యానికి మేలు*/
ఔట్పుట్ తెరమీద
enter the no of fruits of type 1 purchased:10
enter price per unit of this fruit:4
enter the no of fruits of type 2 purchased:6
enter price per unit of this fruit:8
enter the no of fruits of type 3 purchased:5
enter price per unit of this fruit:20
enter the no of fruits of type 4 purchased:12
enter price per unit of this fruit:3
total cost of fruits=224
enter price per unit of this fruit:4
enter the no of fruits of type 2 purchased:6
enter price per unit of this fruit:8
enter the no of fruits of type 3 purchased:5
enter price per unit of this fruit:20
enter the no of fruits of type 4 purchased:12
enter price per unit of this fruit:3
total cost of fruits=224
/*reference NPTEL lecture video on 'Linear Search': Problem Solving through Programming in C, IIT Kharagpur. Prof. Anupam Basu*/
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.