Shubham Bothra - ITMC Notes
Shubham Bothra - ITMC Notes
#include<stdio.h>
#include<conio.h>
Void main()
{
\Variable declaration
\Input to the program
\formulation steps or calculation steps
\Output of a program
Output function:
printf(“ ”);
\n to change line
\t for tab spacing
Input function:
int %d
float %f
double %lf
char %c
long int
Problem: Classify the roots of quadratic equations and create the equivalent conditions.
DAY 2
If(condition)
{
//code
If else
Problem: Develope the C program to check whether person is eligible for voting.
Problem: To check whether person is eligible for blood donation. Criterion is age
between 18 to 55 and weight of the person should be 45 and above.
If else ladder
Switch
switch(variable){
case constant1:
statement
break:
case constant2:
statement
break;
case constant3:
statement
break;
case constantN:
statement
break;
default:
statement
switch(ch){
case ‘a’:
case ‘e’:
case ‘i’:
case ‘o’:
case ‘u’:
printf(“Vowel”);
break;
default:
printf(“Consonant”);
}
while(condition){
\\code
}
Problem: Write a program to calculate GCD and LCM of any two number.
LCM=(a*b)/GCD;
GCD=
while(a!=b){
if(a>b){
a=a-b;
}
else b=b-a;
}
do-while
do{
\\code
} while(condition)
Problem: Find the sum of individual digits of a given number.
Jump statements:
1. Break
2. Continue
3. Return
4. Goto label; label:
ARRAY
Problem: write a program to find the maximum number from the array of numbers.
STRING
char a[10]
FUNCTION:
1. Inbuilt functions
Function declaration:
Function call:
(a) If returntype is void, then syntax is:
functionname(only names of parameter & no datatype);
(b) If returntype is other than void, then syntax is:
Resultvariable=functionname(only names of parameter);
STRUCTURE:
OBJECT ORIENTED PROGRAMING: CLASS CONCEPT
class concept:
class classroom{
private: (no access outside the class, only use from within the class)
//members (include variable/function or both)
public: (full access outside to the class)
//members
protected: (can be used by outside by child/derived class)
//members
};
Problem: Develop the C++ application to calculate simple interest and compound
interest. Aplication should have three different functions:
class Test{
private:
int a;
float b;
static int c;
public:
void abc(){
//code
}
INHERITENCE:
Example:
class Emp
{
// code
};
Emp
Getdata()
Name
putdata() Id
salary
Manager Scientist
………………………………………………………………………………………………………………………...
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class Emp{
private:char name[20];int id;float salary;
public: void getdata(){
fflush(stdin);
cout<<"Enter the name, id and salary\n";
cin>>name>>id>>salary;}
void putdata(){
fflush(stdin);
cout<<"\n\nName="<<name<<"\nID="<<id<<"\nSalary="<<salary<<endl;}
};
class Manager : public Emp{
private:int teamsize, projects;
public: void getdata(){
fflush(stdin);
Emp::getdata();
cout<<"\nEnter teamsize and number of projects handled\n";
cin>>teamsize>>projects;}
void putdata(){
fflush(stdin);
Emp putdata();
cout<<"TeamSize="<<teamsize<<"\nNumber of projects
handled="<<projects<<endl;}
};
class Scientist : public Emp
{
private:int pub, patents;
public: void getdata(){
fflush(stdin);
Emp::getdata();
cout<<"\nEnter the number of Publications and Patents";
cin>>pub>>patents;}
void putdata(){
fflush(stdin);
Emp putdata();
cout<<"Publications="<<pub<<"\nPatents="<<patents<<endl;}
};
void main(){
Manager m;
Scientist s;
clrscr();
cout<<"Enter the manager info\n";
m.getdata();
cout<<"\nManager info is:\n";
m.putdata();
cout<<"Enter the Scientist info\n";
s.getdata();
cout<<"\nScientist info is:\n";
s.putdata();
getch();
}
TEMPLATE:
This allows a function or class to work on many different data types without being
……..PPT
example below:
DAY 6
EXCEPTION HANDLING:
Runtime error at any code and syntax error (try, throw, catch)
FILE HANDLING: