Posts

Simple calculator using class in c++

#include <iostream> using namespace std; class calc{ int num1, num2; public:     void div()     {         int a, b;         float result;         cout<<"enter first number \n";         cin>>a;         cout<<"enter your second number \n";         cin>>b;         result=a/b;         cout<<"division done, output is : "<<result<<endl;     }      void sum()     {         int output;         cout<<"enter your first number \n";         cin>>num1;         cout<<"enter your second number \n";         cin>>num2;         output=num1+num2;         cout...

C++ for banking transaction demo

//lastbenchers.org #include <iostream> using namespace std; class transaction //declaration of class {  int amount=10000; //private data member public: //starting public function      void usercheck()     {         int user, password; // declaration of user id and password         cout<<"enter your user id \n";         cin>>user;         cout<<"enter your password \n";         cin>>password;         if(user==123456 && password==1234) // checking login details         {             //int user, password;             int choice;             cout<<"you have logged in successfully \n";             abc:            ...

Display name of five students using structure in c.

if we do not use any loop in our file. then a programme will take more time and coding will be too long.  an example is following:-  #include <stdio.h> #include <stdlib.h> struct student {     char name1[50];     char name2[50];     char name3[50];     char name4[50];     char name5[50]; }s; int main() {     printf("enter name of 1s students\n");     scanf("%s",s.name1);     printf("enter name of 2 students\n");     scanf("%s",s.name2);     printf("enter name of 3 students\n");     scanf("%s",s.name3);     printf("enter name of 4 students\n");     scanf("%s",s.name4);     printf("enter name of 5 students\n");     scanf("%s",s.name5);     // displaying name     printf("displaying name of five students \n");     printf("name of 1 student : \n");     ...

calculate average marks of five students using array of structure in c.

#include<stdio.h>         struct student         {           int sub1;           int sub2;           int sub3;           int sub4;           int sub5;         };             void main()         {              struct student s[10];              int i,j,fn,sum=0,total=0;              float a;              for(i=0;i<=4;i++)                  {                         printf("\nEnter Marks in five Subjects = ");                        ...