Tuesday, 31 July 2018

C Program To Find Mode Value In Array

                    Finding Mode Value In Array

#include <stdio.h>

int mode(int arr[], int size); // function prototype

int main(void){
// in following simple program we will create a function which will accept an array as an input
// Furthermore that function will return mode value from the array elements
// mode value is the most repeated value of the elements
int arrayName[10] = {2,4,4,4,1,2,3,4,2,3}; // defined an array with 10 elements
//output each element of array
printf("Original values of the array\n\n");
printf("Array index\t\t\tValue\n");
for(int j=0; j<10; j++){
printf("%11d\t\t\t%4d\n", j, arrayName[j]);
}
int a = mode(arrayName, 10); // function call
printf("\n\nMode Value is: %d", a);
return 0;
}

//function definition
int mode(int arr[], int size){
int freq[size] = {0};
for(int i=0; i<size; i++){
freq[arr[i]]++;
}
printf("\nFrequency of each array element\n\n");
printf("Array index\t\t\tValue\n");
for(int j=0; j<10; j++){
printf("%11d\t\t\t%4d\n", j, freq[j]);
}
int largest = 0;
for (int j=0; j<size; j++){
if(freq[j]>freq[largest]){
largest = j;
}
}
printf("\nFrequency of each array element (graphical representation)\n\n");
printf("Array index\t\t\tFrequency\n");
for(int i=0; i<size; i++){
printf("%11d\t\t\t",i);
for(int j=0; j<freq[i]; j++){
printf("*");
}
printf("\n");
}
return largest;

}OUTPUT:-

          0                        0
          1                        1
          2                        3
          3                        2
          4                        4
          5                        0
          6                        0
          7                        0
          8                        0
          9                        0

Frequency of each array element (graphical representation)

Array index                     Frequency
          0
          1                     *
          2                     ***
          3                     **
          4                     ****
          5
          6
          7
          8
          9


Mode Value is: 4

Thursday, 26 July 2018

Sum of Array In C Language


SUM OF ARRAY IN C LANGUAGE:-

#include<stdio.h>
int sum(int a[],int s);
int main()
{
int add;
int s=10;
int arr[s]={1,1,1,1,1,1,1,1,1,1};
int ary[s]={1,1,1,1,1,1,1,1,1,1};
add=sum(arr,s)+sum(ary,s);
printf("Sum of these array=%d",add);
return 0;
}
int sum(int a[],int s)
{
int sum,i;
sum=0;
for(i=0;i<s;i++)
{
sum=sum+a[i];
}

}

OUTPUT:-

Sum of these array=20

Sunday, 22 July 2018

C++ Program Classes Simple Example

Basically These are the Simple Example of  Classes in C++ Program

EXAMPLE:1

#include<iostream>
#include<conio.h>
using namespace std;
class myclass
{
private:
int a,b,c;
public:
void myfun()

{

a=10;
b=20;
c=a+b;
cout<<"Result is:"<<c;
}
};
int main()
{
        myclass obj;
obj.myfun();
getch();
return 0;

}
OUTPUT:-

Result is:30

EXAMPLE:-2

#include<iostream>
#include<conio.h>
using namespace std;
class myclass
{
public:
void myfun(int a,int b)
{
int c;
c=a+b;
cout<<"Result is:"<<c;
}
};
int main()
{
myclass obj;
obj.myfun(100,50);
getch();
return 0;
}
OUTPUT:-

Result is:150

Friday, 20 July 2018

C Program Array Example Multiply by index value

ARRAY EXAMPLE IN C:-

information of this program basically header file include stdio.h then start the main function array declared size is equal to 10 defined an array with 10 element then print function use show screen in original values of array then for loop used initial value in 0 for loop exceute in less then 10 then  array index values multiply by 5 then show the result

CODE:-

#include <stdio.h>

int main(void){
// array is a type of variable which can store multiple items of the same data type
// in following simple program we will define an array of 10 elements
//After that we will multiply each element of array with 5 and then we will output the value of each element of the array

int arrayName[10] = {1,2,3,4,5,6,7,8,9,10,}; // defined an array with 10 elements

//output each element of array
printf("Original values of the array\n\n");
printf("Array index\t\t\tValue\n");
for(int i=0; i<10; i++)
{
printf("%11d\t\t\t%4d\n", i, arrayName[i]);
}

//output each element of array
printf("\n\nValues of the array after multiplication\n\n");
printf("Array index\t\t\tValue\n");
for(int i=0; i<10; i++)
{
arrayName[i] = arrayName[i] * 5;
printf("%11d\t\t\t%4d\n", i, arrayName[i]);
}


return 0;
}

Friday, 13 July 2018

C++ Program Ask To The User To Enter The Marks Obtained In 3 Subjects To Calculate and Display the Percentage Marks and Grade:

C++ Program Result card Sum,Percentage,Grade

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int sum,eng,math,bio,grade,percentage;
cout<<"Enter The marks of Eng:";
cin>>eng;
cout<<"Enter the marks of Math:";
cin>>math;
cout<<"Enter the marks of bio:";
cin>>bio;
sum=eng+math+bio;
cout<<sum;
percentage=(sum*100)/300;
cout<<endl<<percentage;
cout<<endl<<"Grade:";
if(percentage>=80)
{
cout<<"A";
}
else if(percentage>=70)
{
cout<<"B+";
}
else if(percentage>=60)
{
cout<<"B";
}
else if(percentage>=50)
{
cout<<"C";
}
else
{
cout<<"You are Failed";

}
cout<<endl<<"Thanks";
}

OUTPUT:-

Enter The marks of Eng:77
Enter the marks of Math:77
Enter the marks of bio:66
220
73
Grade:B+
Thanks

C++ Program Add,Product,Multipy


C++ Program Add,Product,Subtract:-

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int a,b,c,sum,product,suntract;
a=10;
b=50;
c=a+b;
cout<<"SUM:";
cout<<c;
c=a*b;
cout<<endl<<"Product:";
cout<<c;
c=a-b;
cout<<endl<<"Subtract:";
cout<<c;

}
OUTPUT:-

SUM:60
Product:500
Subtract:-40

Wednesday, 11 July 2018

For Loop In C Programming Language


FOR LOOP INFORMATION:-

C Programming for LoopLoops are used in programming to repeat a specific block of code. After reading this tutorial, you will learn to create a for loop in C programmingLoops are used in programming to repeat a specific block until some end condition is met.


Example Of  For Loop:-


::

Tuesday, 10 July 2018

What is identifier in C++ Language



Identifiers:-


The Identifiers are the names used to represent Variable, constant, types, functions and label in the program. Identifier is an important feature of all computer languages. A good identifier name should be descriptive but short.

An identifier in C++ may consist of 31 character will be used. The remaining character will be ignored by C++ compiler. Some important rules for identifier name are as follows:

1. The first character must be an alphabetic or underscore ( ).

2. The identifier name must consist of only alphabetical characters, digits or underscores.

3. The reserved word cannot be used as identifier name.

Types Of Identifiers:-

C++ provides the following types of identifiers:
 Standard Identifiers
 User-defined identifiers
Standard Identifiers:-
A type of Identifier that has special meaning in C++ is Known as standard identifiers.

Example:-

Cout and cin are example of standard identifiers. These are the names of input/output object defined in standard input/output library iostream.h
User-defined Identifiers:-
The Type of identifiers that is defined by the programmer to acess memory location is known as user-defined identifier. is use to store data
Example:-
Some examples of user-defined identifiers are a, marks and age etc.

C++ Program Sum Of Two Number


Information Of this Program In Add Two Number:-

Sum Of Two Number in C++ First of all in this program C++ Program add two number start the header file include iostream then start the main function then the three variable declared the a,b,c the assign the value of a and assign the value of b the store the result in c variable then cout the result in screen

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,c;

a=20;

b=30;

c=a+b;

cout<<"Sum Of two number"<<c;

}

OUTPUT:-

Sum Of to number 50

C++ Program Swap Two Number


Learn about Swap Two Number:-

Swap Two Values In C++ First of all in this program swap two number first header file include iostream then start the main function three variable declared a,b and temp variable then user enter first number then first number store in a variable then user enter the second number then second number store the b variable then formula use to swap the number.

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,temp;

cout<<"Enter the first number:";

cin>>a;

cout<<"Enter the second number:";

cin>>b;

cout<<"you input the number as"<<a<<"and"<<b<<endl;

temp=a;

a=b;

b=temp;

cout<<"The Values after swapping are"<<a<<"and"<<b<<endl;

}

OUTPUT:-

Enter the first number:30
 Enter the second number:40 
 you input the number as 30 and 40 
 The Values after swapping are 40 and 30

Product Of Two Number in C++


Information Of This program Product Of two Number:-

Product Of Two Number in C++ First of all in this program C++ Program Product two number start the header file include iostream then start the main function then the three variable declared the a,b,c the assign the value of a and assign the value of b the store the result in c variable then cout the result in screen

CODE:-

#include<iostream>

using namespace std;

int main()

{

int a,b,c;


a=10;


b=10;


c=a*b;


cout<<"Product Of two number:"<<c;


}

OUTPUT:-

Product Of two number:100

History Of C++ Language and Features



Information Of C++ Language:-

Many new programming language appeared during the 1960s. The Computers at that time were still in early stage of development. The Language ALGOL 60  was developed as an alternative to FORTRAN. The Language CPL(combined programming language ) was developed in 1963. It was more specific for concrete programming tasks of that tome than ALGOL or FORTRAN. But it was very difficult  to learn .  Martin Richards developed BCPL (Basic Combined Programming Language) in 1967 that was simplification of CPL
it was originally named “C with Class” . it was enhancement to C language. It allows the use of a Programming technique  Known as Object oriented Programming (OOP).

Feature Of C++:-

  •  Convenient Language
  • Well-Structured Language
  • Case Sensitivity
  • Machine Independence
  • Object Oriented
  • Modular Programming
  • Standard Libraries
  • Hardware Control
  • Brevity
  • Speed
  • Popular Language
  • C Compatibility

Monday, 9 July 2018

C program Use if Statement Compare Number

If Statement:-

Compare Number Use if statement first of all Header file include <stdio.h> then star main function In this program uses six if statement compare two numbers entered by the user.if the condition in any of these if statement is true,the printf statement associated with that if executes.The program and three sample execution output

CODE:-

#include<stdio.h>
int main()
{
int num1;//first number to be read from user

int num2;//second number to be read fromn user
printf("Enter two integers,and i will tell you\n");

printf("the relationships they satisfy: ");
scanf("%d%d",&num1,&num2);//read two integers
if( num1==num2)
{
printf("%d is equal to %d\n",num1,num2);
}//end if
if( num1!=num2)
{
printf("%d is not eual to %d\n",num1,num2);
}//end if
if(num1<num2)
{
printf("%d is less than %d\n",num1,num2);
}//end if
if(num1>num2)
{
printf("%d is greater than %d\n",num1,num2);
}
if(num1<=num2)
{
printf("%d is less than or equal to %d\n",num1,num2);
}//end if
if(num1>=num2)
{
printf("%d is greater than or equal to %d\n",num1,num2);
}//end if
} //end function main

OUTPUT:-

Enter two integers,and i will tell you
the relationships they satisfy: 12 33
12 is not eual to 33
12 is less than 33
12 is less than or equal to 33

Conditional Operator And Example

Conditional Operator:-

Conditional Operator is a decision-making structure . it can be used in place of simple if-else structure. it also called ternary Operator as it uses three operands

Example:-

#include<stdio.h>
int main()
{
int x,y;
printf("Enter two numbers:");
scanf("%d %d", &x,&y);
    x > y ? printf("%d is larger",x):printf("%d is larger",y);
}

Output:-

Enter two numbers: 12 50
50 is larger

What is nested if statement?Explain its Working

Nested if Statement:-
An if statement within an if statement is called nested if statement. in nested structure, the control enters into the inner if only when the outer condition is true. Only one block of statements are executed and the remaining blocks are skipped automatically.
The user can use as many if statement inside another if statement  as required. The increase in the level of complexity of nested if statement.
Syntax:-

Table Print in C Language


Information Of This Program:-
Table Print in C Language First Of all in this Program table Print fist Header file stdio.h include then start the main function then two variable declared a and b then user enter a number   then for loop start table we need to iterate from 1 to 5. Run a loop from 1 to 15, increment 1 on each iteration. The loop structure should look like for(b=1; b<=5; b++).
CODE:-
#include <stdio.h>
int main()
{
int a, b;
printf("Enter an integer: ");
scanf("%d",&a);
for(b=1; b<=5; b++)
{
printf("%d * %d = %d \n", a,b, a*b);
}
return 0;
}
OUTPUT:-
Enter an integer:5
5*1=5
5*2=10
5*3=15
5*4=20
5*5=25

History Of C Language

                                 HISTORY OF C LANGUAGE:-


Information Of C++ Language:-
C Language History
Many new programming language appeared during the 1960s. The Computers at that time were still in early stage of development. The Language ALGOL 60  was developed as an alternative to FORTRAN. The Language CPL(combined programming language ) was developed in 1963. It was more specific for concrete programming tasks of that tome than ALGOL or FORTRAN. But it was very difficult  to learn .  Martin Richards developed BCPL (Basic Combined Programming Language) in 1967 that was simplification of CPL
it was originally named “C with Class” . it was enhancement to C language. It allows the use of a Programming technique  Known as Object oriented Programming (OOP)
Feature Of C++:-
  •  Convenient Language
  • Well-Structured Language
  • Case Sensitivity
  • Machine Independence
  • Object Oriented
  • Modular Programming
  • Standard Libraries
  • Hardware Control
  • Brevity
  • Speed
  • Popular Language
  • C Compatibility

C Program Swap Two Numbers

                               Swap Two Numbers:-

C program Swapping Of Two Number in this program swap two Numbers first of all use standard library then star main function declare three variable x,y and temp then run time user enter the value of  x and y then swap each other
CODE:-
#include <stdio.h>//standard library
int main()//start main function
{
int x;//declare integer variable x
int y;//declare integer variable y
int temp;//declare temp variable
printf("Enter the value of x and y\n");
scanf("%d%d", &x, &y);
printf("Before Swapping\nx = %d\ny = %d\n",x,y);
temp = x;//Basic formula swapping the number
x = y;
y = temp;
printf("After Swapping\nx = %d\ny = %d\n",x,y);
return 0;
}

C Language Learn If-else Selection Statement

Learn about If-else Statement:-

If-else Selection Statement || If else in C Language The if selection statement performs an indicated action only when the condition is true otherwise the action is skip .The if…else selection allows you to specify that different actions are to be performed when the condition is true and  when it’s false.

EXAMPLE:

If students grade is greater than or equal to 60
Print "passed"
else
print "Failed"
prints passed if the students is greater than or equal to 60 and Failed if the student’s grade is less than 60.in either case ,after printing occurs, the next pseudocode statement in sequence is “performed” .The body of the else is also indented.
Simple example
If ( grade >= 60){
Printf ("Passed");
}
else{
Printf ("Failed");
}//end else

C Program Multiply Two Number


                        C Program Multiply Two Number:-




First of all  let three variable a,b,c and the simply first number store in a and and second number in store b then multiply of  two value store in c  

#include<stdio.h>
int main()
{
     int a,b,c;
     printf("Enter The First number:");
     scanf("%d%",&a);
     printf("Enter the Second Number:");
     scanf("%d",&b);
     c=a*b;
     printf("%d*%d=%d",a,b,c);
     return 0;
}


OUTPUT:-

Enter the First Number:5
Enter The Second number:5
5*5=25