"Some of the brightest minds in the country can be found on the last benches of the classroom" Dr. A. P. J. Abdul Kalam
Tuesday, 23 October 2018
Thursday, 11 October 2018
C Program to Insert Node at The End of Single Linked List
Single Linked List: - Simply a list is a sequence of data, and the linked list is a sequence of data linked with each other.
The formal definition of a single linked list is as follows.
The formal definition of a single linked list is as follows.
The single linked list is a sequence of elements in which every element has link to its next element in the sequence.
In any single linked list, the individual element is called as "Node". Every "Node" contains two fields, data and next. The data field is used to store the actual value of that node and the next field is used to store the address of the next node in the sequence.
- #include <stdio.h>
- #include <stdlib.h>
- #include <malloc.h>
- struct node
- {
- int data;
- struct node *next;
- };
- struct node *start;
- void creat_node(int);
- void creat_nodee(int);
- void print();
- int main()
- {
- int data,i,n,neww;
- printf("Plese Enter the Length of the Linked List:\n");
- scanf("%d",&n);
- for(i=0;i<n;i++)
- {
- printf("Please Enter A Value:\n");
- scanf("%d",&data);
- creat_node(data);
- }
- print();
- printf("Please Enter A Value to be Insert at the End of the Linked LIST:\n");
- scanf("%d",&neww);
- creat_nodee(neww);
- print();
- }
- void creat_node(int x)
- {
- struct node *t,*t1;
- t=(struct node*)malloc(sizeof(struct node));
- t->data=x;
- t->next=NULL;
- if(start==NULL)
- {
- start=t;
- }
- else
- {
- t1=start;
- while(t1->next!=NULL)
- {
- t1=t1->next;
- }
- t1->next=t;
- }
- }
- void creat_nodee(int x)
- {
- struct node *t,*t1;
- t=(struct node*)malloc(sizeof(struct node));
- t->data=x;
- t->next=NULL;
- t1=start;
- while(t1->next!=NULL)
- {
- t1=t1->next;
- }
- t1->next=t;
- }
- void print()
- {
- struct node *t;
- t=start;
- while(t->next!=NULL)
- {
- printf("Your Entered DATA was: %d \n",t->data);
- t=t->next;
- }
- printf("Your Entered DATA was (END): %d \n",t->data);
- }
Sunday, 9 September 2018
C Program for Verifying or Identifying A Number is a Armstrong Number or Not | C Program for Armstrong Number |
This Program is for Verifying or Identifying A Number is an Armstrong Number or Not,
This program is applicable for identifying any digits of a number is Armstrong number or not.
#include <stdio.h>
main()
{
int number,temp,i=0,j=0,result=0,power,dig,remain;
printf("\nEnter Any Number:\n");
scanf("%d",&number);
temp=number;
while(temp!=0) //for(temp=number;temp!=0;temp/=10) {i++}
{
temp/=10; //temp=temp/10;
i++;
}
printf("\nYOU HAVE ENTERED The Number %d Which is A %d DIGIT Number",number,i);
for(temp=number;temp!=0;temp/=10)
{
printf("\n\nAfter %d Loop Temp Value is \t %d\n\n",j,temp);
power=1;
remain=temp%10;
printf("\n Remain is %d \t When Temp Value is = %d",remain,temp);
dig=i;
for(i=0;i<dig;i++)
{
power*=remain; //power = power*remain;
}
printf("\n Power Value = %d \t When Temp Value is = %d",power,temp);
result+=power; //result = result+power;
printf("\n Result Value = %d \t When \t Temp Value is = %d",result,temp);
j++;
}
if(result==number)
{
printf("\n\nUltimate Result\n\nYou Have Entered %d Number and It is a Armstrong Number as \nResult = \t %d and Number = \t %d is Same",number,result,number);
}
else
{
printf("\n\nUltimate Result\n\nYou Have Entered %d Number and It is NOT a Armstrong Number as \nResult = \t %d and Number = \t %d is NOT Same",number,result,number);
}
}
RESULT WILL BE LIKE THAT >>
Wednesday, 29 August 2018
C Program For Printing Matrix & Sum of the Values in Each Rows Using The Concept of 2D / Two dimensional array and FOR Loop | C Program for Printing Values in Matrix Form & Sum of the Values in Each Rows By Using Two Dimensional Array and FOR Loop
C Program For Printing Matrix & Sum of the Values in Each Rows Using The Concept of 2D / Two-dimensional array and FOR Loop
C Program for Printing Values in Matrix Form & Sum of the Values in Each Rows By Using Two Dimensional Array and FOR Loop
2D / Two-dimensional array :- A 2D array has a type such as int[][] or String[][], withtwo pairs of square brackets. The elements of a 2D array are arranged in rows and columns, and the new operator for 2D arrays specifies both the number of rows and the number of columns.
An array of arrays is known as a 2D array. The two dimensional (2D) array in C programming is also known as matrix. A matrix can be represented as a table of rows and columns. Before we discuss more about two Dimensional array lets have a look at the following C program
The simplest form of multidimensional array is the two-dimensional array. A two-dimensional array is, in essence, a list of one-dimensional arrays. To declare a two-dimensional integer array of size [x][y], you would write something as follows − Type arrayName [x][y]
Where type can be any valid C data type and arrayName will be a valid C identifier. A two-dimensional array can be considered as a table which will have x number of rows and y number of columns. A two-dimensional array a, which contains three rows and four columns can be shown as follows −
Thus, every element in the array a is identified by an element name of the form a[ i ][ j ], where 'a' is the name of the array, and 'i' and 'j' are the subscripts that uniquely identify each element in 'a'.
C Program For Printing Matrix & Sum of the Values in Each Rows of that Matrix Using The Concept of 2D / Two-dimensional array and FOR Loop -
Type 1 ->>
#include <stdio.h>
main()
{
int a,b,i,j,sum; //Some integer type variable declared
printf("\nEnter Rows and Coloumn:\n");
scanf("%d %d",&a,&b); //Enter the values for number of rows and number of columns
printf("\nRows = %d \n and \n Coloumn = %d\n",a,b);
int k[a][b]; //2D Array declared
printf("\nEnter A Values\n");
for(i=0;i<a;i++) //For loop for Rows
{
for(j=0;j<b;j++) //For loop for column
{
scanf("%d",&k[i][j]); //Values of the matrix given here
printf("\n %6d (%d %d)\n",k[i][j],i+1,j+1); //Printing the given value with the same number like row number and column number For visualisation whole concept
}
}
printf("\nYour Matrex \n\n\n");
printf("\n Result\n");
for(i=0;i<a;i++) //For loop for Rows
{
sum=0; //
for(j=0;j<b;j++) //For Columns
{
printf("%6d",k[i][j]); //Printing the whole matrix
sum+=k[i][j]; //Addition of values in each row
}
printf("%15d",sum); //Printing the all or total value of addition
}
}
Type 2 ->>
#include <stdio.h>
main()
{
int a,b,i,j,sum;
//Some integer type variable declared
printf("\nEnter Rows and Coloumn:\n");
scanf("%d %d",&a,&b);
//Enter the values for number of rows and number of columns
printf("\nRows = %d \n and \n Coloumn = %d\n",a,b);
int k[a][b];
//2D Array declared
printf("\nEnter A Values\n");
for(i=0;i<a;i++)
//For loop for Rows
{
for(j=0;j<b;j++)
//For loop for column
{
scanf("%d",&k[i][j]);
//Values of the matrix given here
printf("\n %6d (%d %d)\n",k[i][j],i+1,j+1);
//Printing the given value with the same number like row number and column number For visualisation whole concept
}
}
printf("\nYour Matrex \n\n\n");
for(i=0;i<a;i++)
//For loop for Rows
{
sum=0;
for(j=0;j<b;j++)
//For loop for column
{
printf("%6d",k[i][j]);
//Printing the whole matrix
sum+=k[i][j];
//Addition of values in each row
}
printf(" Result = %6d",sum); //Printing the all or total value of addition
printf("\n\n");
}
}
Monday, 27 August 2018
C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |
C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |
/*C Program to Find Log(n) Value Using For Loop | Program for Finding Logarithm Value using For Loop |*//* Program Developed by Anupam Dutta */
#include <stdio.h>
#include <math.h>
main()
{
int num,number,i,k; //Variable declaration
printf("\nAll Values Should be a Integer\n\nFloat Number Will not be applicable\n");
printf("Enter A Value:\n"); //A integer value should be entered
scanf("%d",&num);
number=num; //Value of 'num' will be assigned to 'number'
printf("Enter A Base Value:\n"); //Enter the base value of log
scanf("%d",&k); //Scanning the entered value
for(i=1;num!=k;i++) //For Loop
{
num=num/k;
}
printf("%d",i);
printf("\n Log Base = (%d)^(%d) = (%d)",k,number,i); //Printing the result
printf("\n X(%d)^Y(%d) = Z(%d)",k,i,number); //Printing the result
main();
}
Sunday, 26 August 2018
C Program for Sum of Odd and Even Number Separately From 0 to Given Value Using For Loop & If and Else Function
C Program for Sum of Odd and Even Number Separately From 0 to Given Value Using For Loop & If and Else Function
#include <stdio.h>
main()
{
int num,i,n,sumodd=0,sumevv=0; /*Declaration of variables and some variables like sumodd & sumevv are also declared and initialised with the value of zero */
printf("Enter A Value for Loop:\n"); /*Need the number or the value of the number of loops in for loop*/
scanf("%d",&n);
printf("Enter Values to be Sum\n"); /*Enter those numbers that will be added to the for loop at a later time*/
for(i=1;i<=n;i++)
{
num=i; /* provided numbers*/
if(num%2==0)
/*If else condition for detecting odd and even number*/
/*Even number divided by 2 the remainder will be zero so the even number will go in the IF condition the odd number divided by 2 the remainder will not be zero so the odd number will go for ELSE condition*/
{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumevv+=num; //sumevv=sumevv+num;
}
else
{
continue;
}
}
else
{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumodd+=num; //sumodd=sumodd+num;
}
else
{
continue;
}
}
}
printf("\nODD SUM = %d",sumodd); /*For printing the sum of odd numbers*/
printf("\nEVEN SUM = %d",sumevv); /*
For printing the sum of even numbers*/
}
Saturday, 25 August 2018
C Program for Sum of Odd and Even Number Separately Using For Loop & If and Else Function | Dev C++ | TurboC |
C Program for Sum of Odd and Even Number Separately Using For Loop & If and Else Function
#include <stdio.h>
main()
{
int num,i,n,sumodd=0,sumevv=0; /*Declaration of variables and some variables like sumodd & sumevv are also declared and initialised with the value of zero */
printf("Enter A Value for Loop:\n"); /*Need the number or the value of the number of loops in for loop*/
scanf("%d",&n);
printf("Enter Values to be Sum\n"); /*Enter those numbers that will be added to the for loop at a later time*/
for(i=1;i<=n;i++)
{
scanf("%d",&num); /* provided numbers*/
if(num%2==0)
/*If else condition for detecting odd and even number*/
/*Even number divided by 2 the remainder will be zero so the even number will go in the IF condition the odd number divided by 2 the remainder will not be zero so the odd number will go for ELSE condition*/
{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumevv+=num; //sumevv=sumevv+num;
}
else
{
continue;
}
}
else
{
if(num>0) /* IF ELSE for Only positive or greater than zero integer will be able for addition less than zero or negative valid integer will be rejected */
{
sumodd+=num; //sumodd=sumodd+num;
}
else
{
continue;
}
}
}
printf("\nODD SUM = %d",sumodd); /*For printing the sum of odd numbers*/
printf("\nEVEN SUM = %d",sumevv); /*
For printing the sum of even numbers*/
}
Subscribe to:
Posts (Atom)
Semester Question Papers for Computer Science and Engineering Students 2020 - 2021 | Computer Science and Engineering | MAKAUT | WBUT | Maulana Abul Kalam Azad University of Technology
Computer Science and Engineering 3rd Semester Question Papers Download Question Papers o...
-
W.B.C.H.S.E 11(XI) HIGHER SECONDARY EXAM 2016 EXAM QUESTIONS PDF W.B.C.H.S.E 11(XI) 2016 (2015-2016) EXAM QUESTIONS PDF (*PHYSICS*,*MA...
-
Physics Practical Copy 1 & Copy 2 Class 11 (XI) PDF Download Physics Practical Copy 1 & Copy 2 Class 11 (XI) West Bengal Cou...
-
Questions Papers All Subjects of 3rd Semester The year 2015, 2016,2017 Diploma (Polytechnic) Computer Science & Technology ...