C++ programming
Example 1:
// Created by Nityasha on 16/08/20.
// Copyright © 2020 nityasha. All rights reserved.
//
// Program to calculate circumference of circle
// formula : circumference of circle = 2 x PI x Radius
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[])
{
const float pi = 3.14;
float circumference ;
int radius =2;
circumference =2* M_PI *radius;
cout<<"correct upto two decimal places ="<<circumference<<"\n";
circumference =2* M_PI *radius;
cout<<"correct value using math library constant M_PI ="<<circumference<<"\n";
return 0;
}
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main(int argc, const char * argv[])
{
string name[38];
int marks[38];
for (int i=1; i<=3; i++)
{
cout<<"enter name of student "<<i<<"\n";
cin>>name[i];
cout<<"enter marks";
cin >>marks[i];
}
for (int i=1; i<=3; i++)
{
cout<<"\n=============student"<<i<<"==============\n";
cout<<"student"<<i<<"name: "<<name[i]<<"\n";
cout<<"marks of "<<name[i]<<": "<<marks[i]<<"\n";
}
return 0;
}
Comments
Post a Comment